-
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
[EuiComboBox] Fix delimited search value option creation #3841
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_3841/ |
I wonder if a better option is to update our examples' calls of
Especially in the React async rendering future, I'm wary of using a delay to fix a state update, when that update is tied to waiting for React to re-render in time. |
I went back and forth on whether to designate this a documentation issue or not. The async rendering future argument has me reconsidering my choice. I'll try it out |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3841/ |
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 tested passing a,b,c
and hitting enter and it works. 🎉
The only thing that I noticed is that the empty state that it's showing is the one for the custom options:
There is an empty state for the delimiter on combo_box_options_list.tsx
:
emptyStateContent = (
<div className="euiComboBoxOption__contentWrapper">
<p className="euiComboBoxOption__emptyStateText">
<EuiI18n
token="euiComboBoxOptionsList.delimiterMessage"
default="Add each item separated by {delimiter}"
values={{ delimiter: <strong>{delimiter}</strong> }}
/>
</p>
{hitEnterBadge}
</div>
);
Preview documentation changes for this PR: https://eui.elastic.co/pr_3841/ |
flaky test jenkins test this |
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.
Let's make the options.push(newOption);
-> setOptions([...options, newOption]);
change to all custom-entry examples to help avoid this coming up again in a future variation. Otherwise this LGTM
Preview documentation changes for this PR: https://eui.elastic.co/pr_3841/ |
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.
Thanks for making the changes. I tested again and it looks good! 🎉
* timeout between addCustomOption calls * fix the docs example * delimeter empty state prompt * CL * keep changeable options in state
Summary
Fixes #3794, where a copy-pasted delimited search value would only add the last item in the delimited list.
The problem stemmed from looped
addCustomOption
calls not updatingprops.selectedOptions
fast enough for the nextaddCustomOption
call to have access to the updated list, effectively resetting the selected list each time until the last.BecauseaddCustomOption
is provided by the consumer, we can't control its logic. This proposes a simple no-delaysetTimeout
, which gives enough time to finish the execution queue between calls.Updated the docs example to more appropriately update using the
useState
callback parameter.Other docs change is just an update for best practices: keep data in state so it's more visible to React.
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs- [ ] Added documentation- [ ] Added or updated jest tests