Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit 40c437b

Browse files
committed
Add moveFocusToCalendar parameter to show()
1 parent a894991 commit 40c437b

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ Sets focus on the date picker's input. Use this method instead of the global `fo
155155

156156
Type: `Promise<void>`
157157

158-
### `show() => Promise<void>`
158+
### `show(moveFocusToCalendar?: boolean) => Promise<void>`
159159

160-
Show the calendar modal, moving focus to the calendar inside.
160+
Show the calendar modal. Set `moveFocusToCalendar` to false to prevent
161+
the focus from moving to the calendar. Default is true.
161162

162163
#### Returns
163164

src/components/duet-date-picker/duet-date-picker.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,20 @@ export class DuetDatePicker implements ComponentInterface {
311311
}
312312

313313
/**
314-
* Show the calendar modal, moving focus to the calendar inside.
314+
* Show the calendar modal. Set `moveFocusToCalendar` to false to prevent
315+
* the focus from moving to the calendar. Default is true.
315316
*/
316-
@Method() async show() {
317+
@Method() async show(moveFocusToCalendar = true) {
317318
this.open = true
318319
this.duetOpen.emit({
319320
component: "duet-date-picker",
320321
})
321-
this.setFocusedDay(parseISODate(this.value) || new Date())
322322

323-
clearTimeout(this.focusTimeoutId)
324-
this.focusTimeoutId = setTimeout(() => this.monthSelectNode.focus(), TRANSITION_MS)
323+
this.setFocusedDay(parseISODate(this.value) || new Date())
324+
if (moveFocusToCalendar) {
325+
clearTimeout(this.focusTimeoutId)
326+
this.focusTimeoutId = setTimeout(() => this.monthSelectNode.focus(), TRANSITION_MS)
327+
}
325328
}
326329

327330
/**

src/components/duet-date-picker/readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ Type: `Promise<void>`
5858

5959

6060

61-
### `show() => Promise<void>`
61+
### `show(moveFocusToCalendar?: boolean) => Promise<void>`
6262

63-
Show the calendar modal, moving focus to the calendar inside.
63+
Show the calendar modal. Set `moveFocusToCalendar` to false to prevent
64+
the focus from moving to the calendar. Default is true.
6465

6566
#### Returns
6667

0 commit comments

Comments
 (0)