Pjb518 / FoundryVTT-Level-Up-Official

An official implementation of the Level Up: Advanced 5th Edition system for FoundryVTT.
MIT License
43 stars 17 forks source link

[Enhancement] Auto focus on the roll button in roll dialogs #253

Open NekroDarkmoon opened 1 year ago

NekroDarkmoon commented 1 year ago

Focus the button element in roll dialogs so that users can just hit enter when a roll dialog is triggered instead of having to navigate to it via the mouse or keyboard.

Pjb518 commented 1 year ago

This isn't the right move for this functionality. Focusing the button at the bottom of the dialog comes with several problems:

1) If the dialog needs to scroll, we're going to be hiding the information at the top of the dialog, which is often the most important bit.

2) If people want to tab to other parts of the dialog, we've already effectively tabbed them to the end, and the next tab may actually take them outside of the dialog.

What we should be doing instead is relying on the normal behaviour of HTML forms. If an HTML form is in focus, pressing enter will trigger a submission of the form if there is an input or button of type submit in the form. We have submit buttons for our roll dialogs, so we should be able to put the form in focus, rather than needing to focus the submission button itself.