Skip to content

Commit 90f1d90

Browse files
fix: update CreateLinkButton to be able to toggle popover visibility (#2316)
* fix: update CreateLinkButton to be able to toggle popover visibility Resolve #2313 * Small fix * Made popover close whenever `state` changes --------- Co-authored-by: Matthew Lipski <matthewlipski@gmail.com>
1 parent 7905c11 commit 90f1d90

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/react/src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export const CreateLinkButton = () => {
8484
};
8585
},
8686
});
87+
useEffect(() => {
88+
setShowPopover(false);
89+
}, [state]);
8790

8891
// Makes Ctrl+K/Meta+K open link creation popover.
8992
useEffect(() => {
@@ -107,7 +110,10 @@ export const CreateLinkButton = () => {
107110
}
108111

109112
return (
110-
<Components.Generic.Popover.Root open={showPopover}>
113+
<Components.Generic.Popover.Root
114+
open={showPopover}
115+
onOpenChange={setShowPopover}
116+
>
111117
<Components.Generic.Popover.Trigger>
112118
{/* TODO: hide tooltip on click */}
113119
<Components.FormattingToolbar.Button
@@ -120,7 +126,7 @@ export const CreateLinkButton = () => {
120126
dict.generic.ctrl_shortcut,
121127
)}
122128
icon={<RiLink />}
123-
onClick={() => setShowPopover(true)}
129+
onClick={() => setShowPopover((open) => !open)}
124130
/>
125131
</Components.Generic.Popover.Trigger>
126132
<Components.Generic.Popover.Content

0 commit comments

Comments
 (0)