question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent behaviour on remove last item (vs remove all items)

See original GitHub issue

Are 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

1reaction
joe-olicommented, Jan 15, 2021

Did you have any other questions or concerns regarding this approach

Thank you, no more questions now that it is clear what to expect.

1reaction
dakurcommented, Jan 14, 2021

@joe-oli I don’t know in which issue I have read it, but the answer – as I understood it – is null for now, but may be rethought to [] in future.

Ha, it’s here: https://github.com/JedWatson/react-select/issues/4293#issuecomment-759601523

  • Clearing the value from isMulit Select will return the value null to be consistent with current implementation.
    • It should be noted that it was discussed that this approach for returning null for multi Select can be confusing and will likely be reverted back to [] in v4.0
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found