Inconsistent behaviour on remove last item (vs remove all items)
See original GitHub issueAre you asking a question?
No.
Are you reporting a bug or runtime error?
An error in your example, a runtime error, and a bug.
An error in your example in this page: https://react-select.com/creatable
Specifically Multi-select text input and the method handleKeyDown;
handleKeyDown = (event: SyntheticKeyboardEvent<HTMLElement>) => {
const { inputValue, value } = this.state;
if (!inputValue) return;
switch (event.key) {
case 'Enter':
case 'Tab':
//... etc...
this.setState({
inputValue: '',
value: [...value, createOption(inputValue)],
});
event.preventDefault();
}
};
The line
value: [...value, createOption(inputValue)],
assumes …value is always an array; this is NOT true;
value becomes null when you remove the last item, by clicking on the individual item;
Herein lies the bug: Inconsistent behaviour when removing the last item. When removing an individual last item (click on small-x), value = null; When removing all items (click on big-x), value = [];
Are you making a feature request?
No. it is a bug fix. Please make the behavior consistent on item removal, so that even your own example works.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
React Hooks showing inconsistent behaviour - Stack Overflow
The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
Read more >Removing Inconsistent Formula Indicators
I am finished now, but the workbook has thousands of cell markers indicating inconsistent formulas. I would like to know if there is...
Read more >Inconsistent BADI Behavior after deleting its implementation
We had to delete and recreate a BADI implementation as certain ... based on your need to regulate single or mass inconsistent entries....
Read more >Excel Tips: A Trick for Finding Inconsistent Data - GCF Global
On the Home tab, go to Sort & Filter > Filter. · Click the filter drop-down arrow in the desired column. · A...
Read more >Python | Remove last K elements of list - GeeksforGeeks
This has its application in the day-day programming when sometimes we require getting all the lists of similar size or removing the last...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you, no more questions now that it is clear what to expect.
Ha, it’s here: https://github.com/JedWatson/react-select/issues/4293#issuecomment-759601523