Skip to content

Commit 02ce871

Browse files
committed
Merge MentionDropdown position watchers
The separate visible watcher installed autoUpdate, and the combined watcher ran updatePosition() directly -- so opening the dropdown computed the position twice (once eagerly, once via autoUpdate's initial callback). Collapse into one watcher that just installs and tears down autoUpdate; its initial callback covers the first layout.
1 parent fc6e132 commit 02ce871

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

client/src/components/ChatGXY/MentionDropdown.vue

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,13 @@ function updatePosition() {
188188
189189
watch(
190190
() => [props.visible, props.mentionType, props.searchText],
191-
() => {
191+
([visible]) => {
192192
selectedIndex.value = 0;
193-
if (props.visible) {
194-
updatePosition();
195-
}
196-
},
197-
);
198-
199-
watch(
200-
() => props.visible,
201-
(visible) => {
202193
if (visible && props.anchorEl && dropdownEl.value) {
194+
// autoUpdate fires its initial callback immediately, so we don't need a separate updatePosition() call
195+
cleanupAutoUpdate?.();
203196
cleanupAutoUpdate = autoUpdate(props.anchorEl, dropdownEl.value, updatePosition);
204-
} else if (cleanupAutoUpdate) {
197+
} else if (!visible && cleanupAutoUpdate) {
205198
cleanupAutoUpdate();
206199
cleanupAutoUpdate = null;
207200
}

0 commit comments

Comments
 (0)