Skip to content

fix(date-field): enhance focus management and dialog behavior in date picker#3381

Draft
anna-lach wants to merge 19 commits into
mainfrom
fix/3074-date-field-focus-can-escape-expanded-date-field-picker-without-collapsing-the-picker
Draft

fix(date-field): enhance focus management and dialog behavior in date picker#3381
anna-lach wants to merge 19 commits into
mainfrom
fix/3074-date-field-focus-can-escape-expanded-date-field-picker-without-collapsing-the-picker

Conversation

@anna-lach

@anna-lach anna-lach commented May 25, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors the sl-date-field component to replace the use of a popover with a native dialog for the calendar picker, improving accessibility and focus management.

Component refactor: popover → dialog

  • Replaced all references to "popover" with "dialog" in code, comments, and tests, and removed popover-specific code and properties such as #popoverJustClosed, offset, and viewportMargin. The dialog is now managed using native dialog APIs and events, with improved accessibility attributes and event handling. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

  • Updated the dialog rendering in the template to remove the popover attribute and related anchor positioning, and to use dialog-specific event handlers (@close, @click, @cancel). [1] [2]

Accessibility and focus management improvements

  • Updated the field button's aria-expanded attribute and related logic to reflect the dialog's open state, and improved dialog accessibility attributes. [1] [2]

Copilot AI review requested due to automatic review settings May 25, 2026 12:20
@changeset-bot

changeset-bot Bot commented May 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 24f9fa9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sl-design-system/date-field Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…ocus-can-escape-expanded-date-field-picker-without-collapsing-the-picker
@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

🕸 Storybook preview

You can view a preview here (commit c241a135c396218f68d080642d41265f45bb99b6).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates sl-date-field to use a modal <dialog>-based date picker with improved focus handling and updated styling/tests to match the new open/close behavior.

Changes:

  • Replace Popover API usage (showPopover/hidePopover, :popover-open) with modal dialog behavior (showModal()/close(), [open]).
  • Improve Escape handling and light-dismiss (backdrop click) behavior, plus explicit focus return logic.
  • Update SCSS and unit tests to reflect dialog open/close semantics and new focus management expectations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/components/date-field/src/date-field.ts Switches the picker overlay to a modal dialog, updates open/close + focus behavior, and adjusts event handling for Escape/backdrop clicks.
packages/components/date-field/src/date-field.spec.ts Updates tests from popover semantics to dialog semantics and adds focus-management coverage for the dialog.
packages/components/date-field/src/date-field.scss Updates visibility styling from :popover-open to [open] and styles the dialog backdrop for the modal dialog.

Comment thread packages/components/date-field/src/date-field.ts
Comment thread packages/components/date-field/src/date-field.ts
Comment thread packages/components/date-field/src/date-field.ts
Comment thread packages/components/date-field/src/date-field.spec.ts
anna-lach added 2 commits May 25, 2026 14:58
…ocus-can-escape-expanded-date-field-picker-without-collapsing-the-picker
Copilot AI review requested due to automatic review settings May 25, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread packages/components/date-field/src/date-field.ts Outdated
Comment thread packages/components/date-field/src/date-field.ts
Comment thread packages/components/date-field/src/date-field.scss
anna-lach added 2 commits May 26, 2026 08:09
…ocus-can-escape-expanded-date-field-picker-without-collapsing-the-picker
Copilot AI review requested due to automatic review settings May 26, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread packages/components/date-field/src/date-field.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment thread packages/components/date-field/src/date-field.ts Outdated
Comment thread packages/components/date-field/src/date-field.ts
Comment thread packages/components/date-field/src/date-field.ts
Comment thread packages/components/date-field/src/date-field.ts
@anna-lach anna-lach requested a review from Copilot May 26, 2026 11:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@a11ymiko a11ymiko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now in Select Day keyboard focus can escape dialog and go to browser controls like URL adress bar. That is wanted behavior that is also similar to behaviors of other dialogs in SLDS.
But in Select Month and Select Tear view focus moves in endless loop between only dialog components and cannot leave dialog to be placed on browser's controls. That is not a violation but this focus order is not similar to Select Day view's and other dialogs in SLDS and that may be not easy to understand by users.
It is recommended to standardize the behavior of focus in each view so in each view user can leave dialog and place focus on browser's controls as it is now true for the Select Day view

…ocus-can-escape-expanded-date-field-picker-without-collapsing-the-picker

# Conflicts:
#	packages/components/date-field/src/date-field.ts
Copilot AI review requested due to automatic review settings June 15, 2026 10:01
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Comment on lines 23 to 29
### Minor Changes

- [#3020](https://github.com/sl-design-system/components/pull/3020) [`738e4a7`](https://github.com/sl-design-system/components/commit/738e4a77005043de2f9977fab9fb04d4fce6369d) - Added

- new elevation.surface.raised.primary token

Fixed

- form input interactive backgrounds (color.background.input.plain.interactive.plain) from plain to bold variants across all themes (e.g., accent.grey.interactive.bold) for better state contrast.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Date field] Focus can escape expanded date-field picker without collapsing the picker.

3 participants