Conversation
Underlaying focus-trap library supports disabling the scroll to currently focussed element.
- Added Cypress test for preventscroll modifier - Resolved merge conflict with inert feature from main - Removed reference to focus-trap internals in docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review: #4578 — Added new modifier to Focus pluginType: Feature What's happening (plain English)
The code change itself is 4 lines — just a passthrough of a focus-trap option. It works correctly. The naming problemHere's what concerns me. Alpine already has two scroll-related modifiers/methods in the focus plugin:
So The Other approaches considered
Changes Made
Test Results24/24 focus tests passing (23 existing + 1 new). CI was passing on the original PR. Build succeeds. Code Review
SecurityNo security concerns identified. VerdictNeeds discussion. The implementation is correct and minimal, but the naming needs a decision before merging. Having My recommendation: if you want this feature, rename it to Zero community engagement (no reactions/comments in ~11 months) suggests this isn't a widely-needed feature, so "no for now" is also reasonable. Reviewed by Claude |
Underlaying focus-trap library supports disabling the scroll to currently focussed element.
This specific usecase is required in my case for Filament which uses Livewire/Alpine under the hood for its modals.
If you have a very lenghty modal with a vertical scrollbar for its content, and you have a focussed element outside your viewport and you click anywhere in the modal (thus blurring the element triggering some Livewire changes) the x-trap gets re-initialized and automatically scrolls you to the focussed element.
This PR adds a new modifier (incl its docs) which effectively sets preventScroll in the options of the underlaying focus-trap instance.
See also: https://github.com/focus-trap/focus-trap#:~:text=and%20selector%20strings.-,preventScroll,-%7Bboolean%7D%3A%20By