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

Don't lose focus due to autofocus when morphing pages #1267

Merged
merged 1 commit into from
May 30, 2024

Conversation

jorgemanrubia
Copy link
Member

@jorgemanrubia jorgemanrubia commented May 30, 2024

Before this change, Turbo would always focus on the first element with [autofocus] when a page refresh with morphing happened (default behavior inherited from PageRenderer). With this change, it will never autofocus when a page refresh with morphing happens.

This is meant to solve the problem where you are writing on a form, and it loses the focus because a broadcasted page refresh arrives.

@jorgemanrubia jorgemanrubia changed the title Don't autofocus when rendering page refreshes with morphing Don't lose focus due to autofocus when morphing pages May 30, 2024
@jorgemanrubia
Copy link
Member Author

I'll look into those tests...

@jorgemanrubia jorgemanrubia marked this pull request as draft May 30, 2024 11:26
@jorgemanrubia jorgemanrubia force-pushed the morph-autofocus branch 3 times, most recently from 8cca8f8 to 2d69a4a Compare May 30, 2024 13:23
@jorgemanrubia jorgemanrubia marked this pull request as ready for review May 30, 2024 13:26
@jorgemanrubia jorgemanrubia force-pushed the morph-autofocus branch 13 times, most recently from 2f4a4d8 to 236d16f Compare May 30, 2024 15:18
Before this change, Turbo would always focus on the first element with `[autofocus]` when a page refresh
with morphing happened  (default behavior inherited from `PageRenderer`). With this change, it will never
autofocus when a page refresh with morphing happens.

This is meant to solve the problem where you are writing on a form, and it loses the focus because a
broadcasted page refresh arrives.
Copy link
Collaborator

@afcapel afcapel left a comment

Choose a reason for hiding this comment

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

Looks good to me, nice one @jorgemanrubia! 🙌

@jorgemanrubia
Copy link
Member Author

Thanks for helping with those tests @afcapel 🙏

@jorgemanrubia jorgemanrubia merged commit c339144 into main May 30, 2024
2 checks passed
@jorgemanrubia jorgemanrubia deleted the morph-autofocus branch May 30, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants