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

Commit

Permalink
Add moveFocusToCalendar parameter to show()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan DeBeasi committed Aug 1, 2022
1 parent a894991 commit b1315d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ Sets focus on the date picker's input. Use this method instead of the global `fo

Type: `Promise<void>`

### `show() => Promise<void>`
### `show(moveFocusToCalendar?: boolean) => Promise<void>`

Show the calendar modal, moving focus to the calendar inside.
Show the calendar modal. Set `moveFocusToCalendar` to false to prevent
the focus from moving to the calendar. Default is true.

#### Returns

Expand Down
13 changes: 8 additions & 5 deletions src/components/duet-date-picker/duet-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,20 @@ export class DuetDatePicker implements ComponentInterface {
}

/**
* Show the calendar modal, moving focus to the calendar inside.
* Show the calendar modal. Set `moveFocusToCalendar` to false to prevent
* the focus from moving to the calendar. Default is true.
*/
@Method() async show() {
@Method() async show(moveFocusToCalendar = true) {
this.open = true
this.duetOpen.emit({
component: "duet-date-picker",
})
this.setFocusedDay(parseISODate(this.value) || new Date())

clearTimeout(this.focusTimeoutId)
this.focusTimeoutId = setTimeout(() => this.monthSelectNode.focus(), TRANSITION_MS)
this.setFocusedDay(parseISODate(this.value) || new Date())
if (moveFocusToCalendar) {
clearTimeout(this.focusTimeoutId)
this.focusTimeoutId = setTimeout(() => this.monthSelectNode.focus(), TRANSITION_MS)
}
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/components/duet-date-picker/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ Type: `Promise<void>`



### `show() => Promise<void>`
### `show(moveFocusToCalendar?: boolean) => Promise<void>`

Show the calendar modal, moving focus to the calendar inside.
Show the calendar modal. Set `moveFocusToCalendar` to false to prevent
the focus from moving to the calendar. Default is true.

#### Returns

Expand Down

0 comments on commit b1315d7

Please sign in to comment.