Skip to content

fix(ui5-calendar): set timestamp of daypicker on mousedown#13527

Open
hinzzx wants to merge 1 commit into
mainfrom
dp-foc-on-mousedown
Open

fix(ui5-calendar): set timestamp of daypicker on mousedown#13527
hinzzx wants to merge 1 commit into
mainfrom
dp-foc-on-mousedown

Conversation

@hinzzx
Copy link
Copy Markdown
Contributor

@hinzzx hinzzx commented May 15, 2026

Overview

Clicking a day in ui5-calendar / ui5-date-picker could move focus to the wrong day.

The root cause

_safelySetTimestamp (which determines the focused date) was only called during the click event, but onAfterRendering fires a focus() call triggered by the preceding mousedown, before click - so focus landed on the previously focused day instead of the clicked one.

What We Did

  • In the day picker, that is a composite component of the calendar, we now set the timestamp on mousedown

What This Fixes

  • Clicking a day now moves focus to that day immediately, even when onAfterRendering fires focus() before the click event resolves

Fixes: #12914

@hinzzx hinzzx requested review from GDamyanov and nnaydenow May 15, 2026 07:48
@ui5-webcomponents-bot
Copy link
Copy Markdown
Collaborator

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview May 15, 2026 07:54 Inactive
Copy link
Copy Markdown
Contributor

@GDamyanov GDamyanov left a comment

Choose a reason for hiding this comment

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

Could we also add test?

}

this._safelySetTimestamp(this._getTimestampFromDom(target));
}
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.

Duplicated logic in _selectDate. this._safelySetTimeStamp is called also in onClick handler and cause one additional re render. So we can add additional variable in _selectDate like setTimestamp = true and call the method in onclick handler with value false since the timestamp is already set in on mouse down handler

@nnaydenow
Copy link
Copy Markdown
Contributor

Screen.Recording.2026-05-15.at.10.59.46.mov

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.

[ui5-calendar]: component move focus

4 participants