-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiColorPicker] onBlur
and data-test-subj
#4822
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_4822/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4822/ |
data-test-subj="colorPickerAnchor" | ||
data-test-subj="test subject string" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to remove the old one? I'd suspect you'd just want to append any custom DTS? Otherwise I'd consider this a breaking change as there might be consumers targeting the old manual DTS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more just validation that a DTS passed by a consumer will get used; test subject string
should've been here previously but we were ignoring the prop and using the manual default.
We could consider this a breaking change because I did switch to using a generated ID rather than colorPickerAnchor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but should it be overriding or appending like with do with custom className
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good point; we could append. I forgot that findTestSubject
uses '~=', // Exists in a space-separated list
by default for selector matching. I'll update.
Would you also like to revert the generated ID change to avoid the breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the manual string is a good approach so that if consumers want to target the EUI supplied one, they can and it doesn't change every render/test run. But the previous one lacked the eui
prefix, so I'd still make the breaking change but use euiColorPickerAnchor
(or something most appropriate but with the eui
prefix).
Preview documentation changes for this PR: https://eui.elastic.co/pr_4822/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Didn't test the the actual onBlur
action.
@@ -283,6 +284,12 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({ | |||
onChange(text, output); | |||
}; | |||
|
|||
const handleOnBlur = () => { | |||
if (!isColorSelectorShown && onBlur) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why the caveat of if !isColorSelectorShown
here? Maybe just add a comment for the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevents onBlur
from being called twice if the popover is open. I'll add a comment 👍
Preview documentation changes for this PR: https://eui.elastic.co/pr_4822/ |
Summary
Fixes #4803 and fixes #4792, two bugs related to prop propagation.
onBlur
callback will get called after leaving the main inputdata-test-subj
configuration is respectedChecklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Props have proper autodocs and playground toggles- [ ] Added documentation- [ ] Checked Code Sandbox works for the any docs examples