diff --git a/packages/ui/src/focus.ts b/packages/ui/src/focus.ts index 3aedb5fd24..820a81b73c 100644 --- a/packages/ui/src/focus.ts +++ b/packages/ui/src/focus.ts @@ -44,13 +44,15 @@ class FocusManagerImpl implements FocusManager { } next (inc?: 1 | -1): void { + if (this.elements.length === 0) return const current = this.elements[this.current] if (!(current?.canBlur?.() ?? true)) { return } - while (true) { + for (let index = 0; index < this.elements.length; index++) { this.current = this.current + (inc ?? 1) - if (this.elements[Math.abs(this.current) % this.elements.length].focus()) { + const el = this.elements[Math.abs(this.current) % this.elements.length] + if (el?.focus()) { return } } diff --git a/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte b/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte index 04e9be3491..33a7b84dab 100644 --- a/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte @@ -35,7 +35,7 @@ $: selectedPriority = value.priority const changePriority = async (newPriority: IssuePriority | undefined) => { - if (!isEditable || newPriority === undefined || value.priority === newPriority) { + if (!isEditable || newPriority == null || value.priority === newPriority) { return } diff --git a/plugins/tracker-resources/src/components/issues/PriorityInlineEditor.svelte b/plugins/tracker-resources/src/components/issues/PriorityInlineEditor.svelte index 25a4d05615..41fc19fa40 100644 --- a/plugins/tracker-resources/src/components/issues/PriorityInlineEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/PriorityInlineEditor.svelte @@ -57,7 +57,7 @@ } const changePriority = async (newPriority: IssuePriority | undefined) => { - if (!isEditable || newPriority === undefined || value === newPriority) { + if (!isEditable || newPriority == null || value === newPriority) { return } diff --git a/plugins/tracker-resources/src/components/issues/StatusEditor.svelte b/plugins/tracker-resources/src/components/issues/StatusEditor.svelte index fb7e417019..4f5b151870 100644 --- a/plugins/tracker-resources/src/components/issues/StatusEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/StatusEditor.svelte @@ -56,7 +56,7 @@ const dispatch = createEventDispatcher() const changeStatus = async (newStatus: Ref | undefined, refocus: boolean = true) => { - if (!isEditable || newStatus === undefined || value.status === newStatus) { + if (!isEditable || newStatus == null || value.status === newStatus) { return } diff --git a/plugins/view-resources/src/components/BooleanEditorPopup.svelte b/plugins/view-resources/src/components/BooleanEditorPopup.svelte index 209a8e1f39..2913bc998a 100644 --- a/plugins/view-resources/src/components/BooleanEditorPopup.svelte +++ b/plugins/view-resources/src/components/BooleanEditorPopup.svelte @@ -39,9 +39,9 @@