Skip to content

Conversation

@lovhb
Copy link

@lovhb lovhb commented Nov 28, 2025

Adds logic to focus input elements with the autofocus attribute using requestAnimationFrame, ensuring proper behavior for dynamically loaded content (like the search widget) and improved compatibility with browsers like Firefox. Should fix #348 and any other autofocusing widget problems.

The problem is that the setupSearchBoxes() function runs after the page content is loaded, and it adds event listeners to the search input. However, the browser's autofocus behavior happens during initial page load, but since the content is loaded asynchronously and inserted via innerHTML, the autofocus attribute doesn't work as expected. I commited a fix that should solve this. It runs focus() on all elements with autofocus enabled after the widgets are added. Might not be the best solution but works for me on both Firefox and Chrome!

Adds logic to focus input elements with the autofocus attribute using requestAnimationFrame, ensuring proper behavior for dynamically loaded content (like the search widget) and improved compatibility with browsers like Firefox. Should fix glanceapp#348
@lovhb lovhb changed the title Fix autofocus handling for search widget #348 Fix autofocus handling for search widget Nov 28, 2025
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.

1 participant