[EuiSuperDatePicker] Fix duplicate value when pasting absolute value #8311
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
Related Kibana issue: elastic/kibana#205633
This PR fixes an issue on
EuiSuperDatePicker
where pasting a date would sometimes result in the date being appended instead of being replaced.The issue was that the
onPaste
event would trigger theonChange
event on theEuiFieldText
input which clashed with the controlled value update. This seemed to be a race condition as depending on application this resulted either in a duplicated value or not, depending on which state was updated first.This behavior is not reproducible on EUI (neither docs not Storybook), but it can be observed by checking the value of the internally used
EuiFieldText
which showed the duplication.The solution is to
preventDefault
ononPaste
and just let the controlled value update the input.before
Screen.Recording.2025-02-07.at.10.40.18.mov
after
Screen.Recording.2025-02-07.at.10.36.00.mov
QA
event.preventDefault
and manually run the test locally (the test should fail)event.preventDefault
on theonPaste
eventevent.target.value
on theonChange
event of theEuiFieldText
onChange
event is not triggered on pastingEuiFieldText` value before the fix
Screen.Recording.2025-02-07.at.10.48.26.mov
EuiFieldText` value after the fix
Screen.Recording.2025-02-07.at.10.49.32.mov
General checklist
Checked in both light and dark modesChecked in mobileAdded documentationProps have proper autodocs (using(https://github.com/elastic/eui/blob/main/wiki/contributing-to-eui/documenting/playgrounds.md)**@default
if default values are missing) and **[playground toggles]Checked Code Sandbox works for any docs examplesUpdated visual regression testsIf applicable, added the breaking change issue label (and filled out the breaking change checklist)If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)