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.

Cannot unselect by clicking selected when using dataAdapter

See original GitHub issue

When using select2 with dataAdapter, the selected option cannot be deselected by clicking it again on list. If no dataAdapter option is used, it works fine, option can be deselected by clicking it second time.

Here’s example with a bug I described, you can select any option and then try to deselect it by clicking it again. http://jsfiddle.net/o53fLqum/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kevin-browncommented, Dec 17, 2021

Figured out the issue.

The id property on data objects must be a string or it won’t be able to match up with the <option> that is created (since <option>.value is always a string). This is why the element property isn’t getting set as expected on the data object which leads to pretty much the rest of the issues we were seeing. Setting the id property to a string in the example jsfiddle solves these issues.

https://select2.org/data-sources/formats#automatic-string-casting

I’m still leaving this open since Select2 should handle this case and automatically cast it, but it looks like something isn’t consistently doing that which is causing issues.

0reactions
jayaddisoncommented, Jul 21, 2022

See: https://github.com/jayaddison/select2/commit/82585672888eead67610556baa46bd7d7b35fdcf

Sorry, ignore this attempt at a fix. I was testing it again using a hand-written select2 example, and this time it isn’t working (the option elements do not exist), so I don’t think it’s valid.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select/Deselect checkbox does not work after selectAll ...
Use this mode. SelectAll handler : // note change event $('input[type="checkbox"][id="selectAll"]').change(function () { converter.
Read more >
Unable to deselect in excel - Microsoft Community Hub
Yesterday when I selected multiple cells in a Microsoft Excel 2016 worksheet, I could hold CTRL key and deselect the cells I wanted...
Read more >
Cannot deselect previously selected row in p-dataTable
In rc.4, the unselect fires with Ctrl+Click. Single click to unselect does not work even for single selection. Multiple selection works with ......
Read more >
UITableView cannot deselect cells … | Apple Developer Forums
On click in the button that activates, tableView is in editing mode, with all cells selected. I could deselect and reselect at will....
Read more >
Is it possible to unselect a cell in DataTable? - Dash Python
Remove or change hotpink selection from Datatable ... would be great if you could click on a cell/row/column to toggle active or selected....
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