Tom Select is a lightweight (~16kb gzipped) hybrid of a textbox and select box. Forked from selectize.js to provide a framework agnostic autocomplete widget with native-feeling keyboard navigation. Useful for tagging, contact lists, etc.
Description:
When Tom Select is initialized on a form field that is set to be autofocused, the field loses its focus immediately upon page load. This issue occurs regardless of whether the autofocus attribute is set directly in the HTML or programmatically via JavaScript. This behavior disrupts user experience, especially in forms where immediate input is expected upon loading the page.
Initialize Tom Select on this input using the standard initialization code.
Load the page in a browser and observe that the input does not retain focus.
Expected Behavior:
The input field should retain its focus when the page loads, allowing users to start typing immediately without having to click on the field.
Actual Behavior:
The input field loses focus as soon as Tom Select is initialized, requiring users to manually click on the field to start typing.
Additional Information:
This issue does not appear to be browser-specific as it replicates across multiple major browsers.
A potential workaround could involve programmatically setting focus back to the input after initializing Tom Select, but this is not ideal for all use cases.
Suggested Fix:
The initialization of Tom Select might benefit from a check to retain focus if the target element has the autofocus attribute or if it is already focused before initialization. Adjusting the library to check and restore focus could resolve this issue.
Bug description
Description: When Tom Select is initialized on a form field that is set to be autofocused, the field loses its focus immediately upon page load. This issue occurs regardless of whether the autofocus attribute is set directly in the HTML or programmatically via JavaScript. This behavior disrupts user experience, especially in forms where immediate input is expected upon loading the page.
initially reported in https://github.com/lovasoa/SQLpage/issues/297
Steps to Reproduce:
autofocus
attribute on this input.Expected Behavior: The input field should retain its focus when the page loads, allowing users to start typing immediately without having to click on the field.
Actual Behavior: The input field loses focus as soon as Tom Select is initialized, requiring users to manually click on the field to start typing.
Additional Information:
Suggested Fix: The initialization of Tom Select might benefit from a check to retain focus if the target element has the
autofocus
attribute or if it is already focused before initialization. Adjusting the library to check and restore focus could resolve this issue.