Fix tab navigation order in issue creation popup (#5148)

Signed-off-by: Ilayda Simsek <ilaydasimsek4@gmail.com>
This commit is contained in:
ilaydasimsek 2024-04-09 13:29:33 +03:00 committed by GitHub
parent 15eab69f91
commit 863a195d4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 3 deletions

View File

@ -26,6 +26,7 @@
import DPCalendar from './icons/DPCalendar.svelte'
import DPCalendarOver from './icons/DPCalendarOver.svelte'
import { getMonthName } from './internal/DateUtils'
import { registerFocus } from '../../focus'
export let value: number | null | undefined
export let mode: DateRangeMode = DateRangeMode.DATE
@ -49,6 +50,7 @@
let currentDate: Date | null = null
if (value != null) currentDate = new Date(value)
let opened: boolean = false
let input: HTMLButtonElement | undefined = undefined
const onChange = (result: Date | null): void => {
if (result === null) {
@ -64,9 +66,30 @@
}
$: withTime = mode !== DateRangeMode.DATE
// Focusable control with index
export let focusIndex = -1
const { idx, focusManager } = registerFocus(focusIndex, {
focus: () => {
input?.focus()
return input != null
},
isFocus: () => document.activeElement === input
})
$: if (idx !== -1 && focusManager) {
focusManager.updateFocus(idx, focusIndex)
}
$: if (input != null) {
input.addEventListener('focus', () => {
focusManager?.setFocus(idx)
})
}
</script>
<button
bind:this={input}
class="datetime-button {kind} {size}"
class:editable
class:dateTimeButtonNoLabel={!shouldShowLabel}

View File

@ -34,6 +34,7 @@
export let justify: 'left' | 'center' = 'center'
export let width: string | undefined = undefined
export let labelDirection: TooltipAlignment | undefined = undefined
export let focusIndex = -1
export let disabled: boolean = false
@ -90,6 +91,7 @@
{kind}
{size}
{justify}
{focusIndex}
showTooltip={{ label: key.attr.label, direction: labelDirection }}
on:click={addTag}
>

View File

@ -932,7 +932,7 @@
}}
/>
<ComponentSelector
focusIndex={8}
focusIndex={7}
value={object.component}
space={_space}
onChange={handleComponentIdChanged}
@ -941,7 +941,7 @@
size={'large'}
/>
<div id="estimation-editor" class="new-line">
<EstimationEditor focusIndex={7} kind={'regular'} size={'large'} value={object} />
<EstimationEditor focusIndex={8} kind={'regular'} size={'large'} value={object} />
</div>
<div id="milestone-editor" class="new-line">
<MilestoneSelector
@ -956,6 +956,7 @@
</div>
<div id="duedate-editor" class="new-line">
<DatePresenter
focusIndex={10}
bind:value={object.dueDate}
labelNull={tracker.string.DueDate}
kind={'regular'}
@ -965,6 +966,7 @@
</div>
<div id="parentissue-editor" class="new-line">
<Button
focusIndex={11}
icon={tracker.icon.Parent}
label={object.parentIssue != null ? tracker.string.RemoveParent : tracker.string.SetParent}
kind={'regular'}
@ -991,7 +993,7 @@
</svelte:fragment>
<svelte:fragment slot="footer">
<Button
focusIndex={10}
focusIndex={12}
icon={IconAttachment}
iconProps={{ fill: 'var(--theme-dark-color)' }}
size={'large'}