fix(ui): prevent Enter key from submitting form in Tags component#4896
Merged
Conversation
Modified the Tags input component to always prevent the default Enter key behavior (form submission), regardless of whether the input has a value. This fixes the issue where pressing Enter in the Values textbox for "IS ONE OF" or "IS NOT ONE OF" constraints would save the entire form instead of just adding a tag. The Enter key now: - Always prevents form submission - Adds a tag only when the input field has a value - Does nothing when the input is empty Fixes #4894 Signed-off-by: Mark Phelps <[email protected]>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a UX issue where pressing Enter in the Tags component's Values textbox would submit the entire constraint form instead of just adding the tag value.
- Restructured the
inputKeyDownfunction to always prevent Enter key's default form submission behavior - Maintains existing functionality where Enter adds a tag only when the input has a value
- Improves user experience by preventing accidental form submissions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2 #4896 +/- ##
===========================================
+ Coverage 33.86% 59.01% +25.15%
===========================================
Files 127 135 +8
Lines 16246 16874 +628
===========================================
+ Hits 5502 9959 +4457
+ Misses 10179 6234 -3945
- Partials 565 681 +116
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the issue where pressing Enter in the Values textbox for "IS ONE OF" or "IS NOT ONE OF" constraints would save the entire constraint form instead of just adding the value as a tag.
Changes
ui/src/components/forms/Tags.tsx: Restructured theinputKeyDownfunction to always prevent the default Enter key behavior (form submission), regardless of whether the input has a value.The Enter key now:
Backward Compatibility
This change improves UX without breaking existing functionality. The Enter key will no longer save the constraint form when pressed in the Values input, which was the undesirable behavior reported in the issue.
Fixes #4894