-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
Select: Preserve value when allowCustomValue
is set
#87843
Conversation
allowCustomValues
is setallowCustomValue
is set
await waitFor(() => expect(screen.getByText('hint: add histogram_quantile')).toBeInTheDocument()); | ||
}); | ||
|
||
it('shows hints for counter metrics', async () => { | ||
const { container } = setup({ |
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 test was duplicated below, so removed it
@@ -111,6 +111,7 @@ describe('useCreatableSelectPersistedBehaviour', () => { | |||
await userEvent.click(input); | |||
|
|||
// we expect 2 elemnts having "Option 2": the input itself and the option. |
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.
// we expect 2 elemnts having "Option 2": the input itself and the option. | |
// we expect 2 elements having "Option 2": the input itself and the option. |
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.
👍 logs changes.
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 this is secretly actually a very big an impactful change... it's a pretty big conceptual change to how custom values work and users interact with them. In saying that, I'm pretty supportive of this - this half-answers a question about fixing this behaviour in the new select component.
Two issues I spotted with it:
When editing a value, trying to click to place the cursor doesn't work. It just closes the dropdown. The only way to move the cursor is to either backspace or use arrow keys.
I think it's only used in plugins, but conincidentally I noticed a style regression with multi select with the noMultiValueWrap
prop enabled.
vs
http://localhost:9001/?path=/story/forms-select--multi-plain-value&args=noMultiValueWrap:!true
yeah i haven't quite found a way to fix that yet. there is one way, but it involves setting the
i see the same behaviour in canary as on this branch? but not on https://developers.grafana.com/ui/latest/index.html?path=/story/forms-select--multi-plain-value&args=noMultiValueWrap:!true so must be something that's regressed recently. will investigate that separately. |
yep, it's caused by #87085 😬 fyi @kaydelaney |
@ashharrison90 i think it's ok to "do nothing. it's the current behaviour of Select anyway. i guess this exposes the problem a little more, but still 🤷" :) I mean - i personally did not find this problematic, thinking about the following proposals, they bring to much of a change to the UX imo. |
I would have hoped we could listen to the click even on the input, handle it there, and prevent it from propagating up to the rest of react-select? Otherwise, I think it's fine (but not ideal) to leave the behaviour as-is then. I think this highlights the existing awkward behaviour even more, but it's probably fine to keep it around for a bit more. 👍 |
also good catch on the weird display issue - when I spotted it it wasn't on canary yet, but I see it now is 👍 |
What is this feature?
SelectBase
<Select>
for editing a custom valueallowCustomValue
is true andisMulti
is falseonMenuOpen
we restore the internal input state to be the selected values labelonMenuClose
we clear the input state elsereact-select
doesn't show theSingleValue
component correctlyonInputChange
we update the internal input value stateWhy do we need this feature?
Who is this feature for?
Which issue(s) does this PR fix?:
Fixes https://github.com/grafana/hyperion-planning/issues/27
Special notes for your reviewer:
Please check that: