mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-03 03:08:12 +08:00
Fix DropdownInput repeated change emitting
This commit is contained in:
@@ -4,11 +4,11 @@
|
|||||||
class="dropdown-box"
|
class="dropdown-box"
|
||||||
:class="{ disabled, open }"
|
:class="{ disabled, open }"
|
||||||
:style="{ minWidth: `${minWidth}px` }"
|
:style="{ minWidth: `${minWidth}px` }"
|
||||||
tabindex="0"
|
|
||||||
@click="() => !disabled && (open = true)"
|
@click="() => !disabled && (open = true)"
|
||||||
@blur="(e: FocusEvent) => blur(e)"
|
@blur="(e: FocusEvent) => blur(e)"
|
||||||
@keydown="(e) => keydown(e)"
|
@keydown="(e) => keydown(e)"
|
||||||
ref="dropdownBox"
|
ref="dropdownBox"
|
||||||
|
tabindex="0"
|
||||||
data-hover-menu-spawner
|
data-hover-menu-spawner
|
||||||
>
|
>
|
||||||
<IconLabel class="dropdown-icon" :icon="activeEntry.icon" v-if="activeEntry.icon" />
|
<IconLabel class="dropdown-icon" :icon="activeEntry.icon" v-if="activeEntry.icon" />
|
||||||
@@ -117,6 +117,7 @@ export default defineComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeEntry: this.makeActiveEntry(this.selectedIndex),
|
activeEntry: this.makeActiveEntry(this.selectedIndex),
|
||||||
|
activeEntrySkipWatcher: false,
|
||||||
open: false,
|
open: false,
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
};
|
};
|
||||||
@@ -124,9 +125,16 @@ export default defineComponent({
|
|||||||
watch: {
|
watch: {
|
||||||
// Called only when `selectedIndex` is changed from outside this component (with v-model)
|
// Called only when `selectedIndex` is changed from outside this component (with v-model)
|
||||||
selectedIndex() {
|
selectedIndex() {
|
||||||
|
this.activeEntrySkipWatcher = true;
|
||||||
this.activeEntry = this.makeActiveEntry();
|
this.activeEntry = this.makeActiveEntry();
|
||||||
},
|
},
|
||||||
|
// Called when `activeEntry` is changed by the `v-model` on this component's MenuList component, or by the `selectedIndex()` watcher above (but we want to skip that case)
|
||||||
activeEntry(newActiveEntry: MenuListEntry) {
|
activeEntry(newActiveEntry: MenuListEntry) {
|
||||||
|
if (this.activeEntrySkipWatcher) {
|
||||||
|
this.activeEntrySkipWatcher = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// `toRaw()` pulls it out of the Vue proxy
|
// `toRaw()` pulls it out of the Vue proxy
|
||||||
if (toRaw(newActiveEntry) === DASH_ENTRY) return;
|
if (toRaw(newActiveEntry) === DASH_ENTRY) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user