Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add initial focus #44

Merged
merged 1 commit into from
Apr 28, 2021
Merged

feat: add initial focus #44

merged 1 commit into from
Apr 28, 2021

Conversation

LukasHirt
Copy link
Contributor

We've added an initial focus so that when the File picker is mounted, it immediately becomes focused.

@LukasHirt LukasHirt added the enhancement New feature or request label Apr 28, 2021
@LukasHirt LukasHirt self-assigned this Apr 28, 2021
@LukasHirt LukasHirt marked this pull request as ready for review April 28, 2021 10:33
Copy link
Contributor

@pascalwengerter pascalwengerter left a comment

Choose a reason for hiding this comment

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

LGTM 🎯

Copy link
Member

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

👍

@kulmann kulmann merged commit 9952f85 into master Apr 28, 2021
@delete-merged-branch delete-merged-branch bot deleted the feat/initial-focus branch April 28, 2021 11:11
@VP-
Copy link

VP- commented May 5, 2021

This does not work when wrapped in a web component. According to the source, mounted() is called before the element is added to the DOM. A focus() does nothing at that point.

Also, if the primary use case of the file picker is a widget, then it should not steal the focus on its own. Instead, the web component should properly handle focus() calls from outside. This would allow the container to decide whether and when the file picker gets the focus.

Handling focus() calls is required anyway to allow proper focus-trapping when used in a modal dialog: Since the dialog might contain other elements, the file picker can't trap the focus only inside itself. So the container has to do it. And since the file picker is typically the first element, then it will need to handle external calls to focus() by forwarding them to the first focusable element inside itself.

@kulmann kulmann mentioned this pull request May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants