Fix #6086: Chips input component doesn't function properly on mobile devices #6088
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #6086, #3885
In this pull request, several modifications were made to address issues with the Chips input component on mobile devices. Here's a breakdown of the changes and their rationale:
- Switch Statement Changed to Use event.key:
The switch statement previously used event.code, which is not available on mobile devices. To ensure compatibility across all devices, the switch statement was updated to use event.key.
- Removal of Code Handling Strange Code 229 for Comma:
A portion of code was removed that handled a specific issue (// GitHub #3885) related to Android Opera browsers generating a strange code 229 for commas. This handling was no longer necessary and was causing unexpected behavior on mobile devices where event.which consistently returned 229 for almost every symbol.
- Addition of onChange Handler:
An onChange handler was added to the input element to access the updated value. This allows for checking if the value ends with props.separator, and if so, removes the separator and calls the addItem function accordingly. This ensures proper handling of input changes, especially on mobile devices.
- Addition of enterKeyHint: "enter" Attribute:
The enterKeyHint: "enter" attribute was added to the input element. This attribute ensures that the enter key doesn't simply change the focus to the next element on mobile devices, where onKeyDown events may not trigger as expected. Instead, it helps maintain focus on the current input and ensures proper functionality of onKeyDown events.
- Flexibility in Separator Handling:
With these changes, the separator can now be almost any symbol, providing greater flexibility and compatibility with various input scenarios.
- Enhanced Backspace Functionality:
With the changes, the backspace key now works as expected for deleting elements on mobile devices, improving overall user experience.
- Testing and Validation:
The changes were thoroughly tested using BrowserStack on Android devices and iOS across different browsers to ensure functionality and compatibility. The modifications were found to resolve the issues and improve the behavior of the Chips input component on mobile devices.
These changes address the reported issues and enhance the usability of the Chips input component, ensuring consistent behavior across different devices and browsers.