Skip to content

Commit 88ff88d

Browse files
fix: closing dropdown after clicking again (#835)
1 parent f04ab1f commit 88ff88d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/super-editor/src/components/toolbar/ButtonGroup.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ const getDropdownAttributes = (option, item) => {
105105
};
106106
107107
const handleClickOutside = (e) => {
108+
const target = e.target;
109+
const itemCtn = target.closest('.toolbar-item-ctn');
110+
const targetItemId = itemCtn?.dataset.itemId;
111+
112+
if (targetItemId === currentItem.value.id) {
113+
return;
114+
}
115+
108116
closeDropdowns();
109117
};
110118
@@ -166,7 +174,6 @@ const handleKeyDown = (e, item) => {
166174
167175
switch (e.key) {
168176
case 'Enter':
169-
console.log('Enter');
170177
handleToolbarButtonClick(item, null, false);
171178
break;
172179
case 'Escape':
@@ -215,6 +222,7 @@ const handleFocus = (e) => {
215222
class="toolbar-item-ctn"
216223
ref="toolbarItemRefs"
217224
:tabindex="index === 0 ? 0 : -1"
225+
:data-item-id="item.id.value"
218226
>
219227
<!-- toolbar separator -->
220228
<ToolbarSeparator v-if="isSeparator(item)" style="width: 20px" />

0 commit comments

Comments
 (0)