From 43a7bf6f876e8ff5734ec8bae2c11f9b7eb31bcc Mon Sep 17 00:00:00 2001 From: the1812 Date: Wed, 10 Jul 2024 22:46:45 +0800 Subject: [PATCH] Fix LaunchBar focus (fix #4808) --- src/components/launch-bar/focus-target.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/launch-bar/focus-target.ts b/src/components/launch-bar/focus-target.ts index 6207ecffd..5c1d50bcc 100644 --- a/src/components/launch-bar/focus-target.ts +++ b/src/components/launch-bar/focus-target.ts @@ -16,8 +16,11 @@ export class FocusTarget extends EventTarget { return this.itemIndex } private set index(value: number) { - this.itemIndex = lodash.clamp(value, -1, this.itemLength - 1) - this.dispatchEvent(new CustomEvent('index-change', { detail: this })) + const newIndex = lodash.clamp(value, -1, this.itemLength - 1) + if (this.itemIndex !== newIndex) { + this.itemIndex = newIndex + this.dispatchEvent(new CustomEvent('index-change', { detail: this })) + } } get hasFocus() { return this.itemIndex > -1