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
Add prevInputValue
to action meta
#4785
Conversation
🦋 Changeset detectedLatest commit: a694069 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a694069:
|
0f27984
to
4ce20e3
Compare
Adding to discussion here to give more transparency. This was discussed internally on a Slack channel. There is some conversation about the naming of the object properties in the actionMeta. While
The idea of these changes makes sense, and while not necessarily required as a part of this PR, it may be useful to introduce the Select Currently, it would need to be done similar to this: const [value, setValue] = useState();
const [inputValue, setInputValue] = useState("");
const onInputChange = (inputValue, { action }) => {
if (action === "input-blur") {
setInputValue(value?.label || "");
}
if (action === "input-change") {
setInputValue(inputValue);
}
};
const onChange = (option) => {
setValue(option);
setInputValue(option?.label || "");
}; Where as I was thinking it could become this: const onInputChange = (inputValue, { action, value }) =>
(action === "input-blur" || action === "set-value")
? (value?.label || '')
: inputValue Introducing the value of the Select into the actionMeta would likely be better named as |
It's |
inputValue
to action metaprevInputValue
to action meta
Thanks @Rall3n! |
Until now if you want to do a feature like keeping the
inputValue
after an option has been selected you would have to manage theinputValue
prop on your own to have access to the previous value.With this PR the need for the extra state would be removed as the current value would be available trough the meta object in the
onInputChange
handler, offering a much better un-controlled behaviour.Before:
After: