Skip to content

Conversation

hinzzx
Copy link
Contributor

@hinzzx hinzzx commented Sep 1, 2025

Currently in our ui5-dynamic-date-range component when user selects an option with Template (e.g. SingleDate, DateRange, Last/Next, etc.) from the List and then clicking the Back Button, when the view switches back to the List with the options, the last clicked option is not being focused.

Now clicking the Back Button no matter if the user selected the date/time or not, switching the view to the List view focus the last clicked list item.

Why we used this approach:

When navigating back, the component re-renders to show the options list.
The focus attempt must happen after the list items are fully rendered in the DOM
Without the await renderFinished and setTimout() in the onAfterRendering hook, this._list.items are empty or the DOM elements might not be ready for focus.

Fixes: #11649

Copy link

cla-assistant bot commented Sep 9, 2025

CLA assistant check
All committers have signed the CLA.

@ui5-webcomponents-bot
Copy link
Collaborator

🚀 Preview deployment ready: https://UI5.github.io/webcomponents/pr-12233/

The preview will be updated automatically when you push new commits to this PR.

@ui5-webcomponents-bot
Copy link
Collaborator

🚀 Preview deployment ready: https://UI5.github.io/webcomponents/pr-12233/

The preview will be updated automatically when you push new commits to this PR.

}

async onAfterRendering() {
await renderFinished();
Copy link
Contributor

Choose a reason for hiding this comment

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

why is renderFinished needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is some kind of race condition where, if we do not have the await renderFinished() sometimes the focus cannot be applied as the List is not yet fully rendered. So with await renderFinished() and setTimeout() we ensure that the focus is called only when everything else is rendered and focusable.

@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Sep 26, 2025

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview September 26, 2025 14:04 Inactive
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-dynamic-date-range: focus goes out of the popover on option backwards navigation
4 participants