Skip to content

Restrict date-picker cursor focus restoration to intentional focus updates #20

Open

Description

@coderabbitai

Summary

Prevent bq-date-picker from moving focus to the calendar cursor on unrelated component updates when focus is outside the picker.

In updated(), the existing !shadowRoot.activeElement condition can call cursor.focus() while the popup is open. An unrelated attribute update, such as a locale change, should not move focus from an outside target.

This behavior predates PR #19. That PR adds support for moving focus from another day during bQuery 1.18 morph rendering. This follow-up is a separate behavior change.

Required changes

  • Review cursor focus restoration in src/components/date-picker/BqDatePicker.ts.
  • Track intentional cursor-moving updates, or use an equivalent explicit focus-intent mechanism.
  • Consume and reset that intent during the update lifecycle so unrelated updates do not trigger cursor focus restoration.
  • Preserve intentional popup-opening behavior, keyboard navigation, and focus behavior for other controls in the picker.
  • Add regression coverage in tests/date-picker.test.ts.

Acceptance criteria

  • When the popup is open and focus is outside the picker, an unrelated update such as changing locale does not move focus to a day button. Use a setup that accounts for the existing focusout and outside-click close handlers.
  • Keyboard navigation still moves DOM focus with the cursor.
  • Opening the popup retains its intended focus behavior.
  • Updates do not move focus from other picker controls to a day unless that move is intentional.
  • Validate against both bQuery 1.18 morph rendering and the supported 1.15.1 replacement-rendering baseline.

Context

Requested by @JosunLP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions