Fix LaunchBar focus (fix #4808)

This commit is contained in:
the1812 2024-07-10 22:46:45 +08:00
parent 4c887a5fae
commit 43a7bf6f87

View File

@ -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