Skip to content
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

Unexpected behavior with create and duplicates enabled #106

Closed
jsicherman opened this issue May 31, 2021 · 10 comments
Closed

Unexpected behavior with create and duplicates enabled #106

jsicherman opened this issue May 31, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@jsicherman
Copy link

jsicherman commented May 31, 2021

Describe the bug
I've created a tom-select with create: true, duplicates: true. When removing a duplicate value from this tom-select (by pressing backspace), the deleted element isn't always at the caret position and sometimes deletes multiple copies of the duplicated value (while throwing an error, below).

To Reproduce
Steps to reproduce the behavior:

  1. Create a tom-select input with duplicates and create enabled
  2. Enter some values including at least some duplicates
  3. Delete values using backspace. When removing a value that has multiple copies, the bug will occur.

Expected behavior
The element(s) should be deleted.

Additional context
Error message as follows (using latest dist):

Uncaught TypeError: t.options[s] is undefined
    updateOriginalInput tom-select.ts:2077
    removeItem tom-select.ts:1887
    removeOption tom-select.ts:1646
    removeItem tom-select.ts:1880
    deleteSelection tom-select.ts:2266
    onKeyDown tom-select.ts:691
    setup tom-select.ts:324
    C utils.ts:128
    setup tom-select.ts:324
    R tom-select.ts:157
    <anonymous> initialize.js:5
    jQuery 8
    onopen shinyapp.js:94
    createSocket shinyapp.js:91
    connect shinyapp.js:36
    initShiny init_shiny.js:551
    setTimeout handler* init_shiny.js:583
    jQuery 13
tom-select.ts:2077:4
@jsicherman jsicherman added the bug Something isn't working label May 31, 2021
@oyejorge
Copy link
Member

oyejorge commented Jun 1, 2021

Hmm, I'm not seeing any errors. Do you get them with this example?

@jsicherman
Copy link
Author

I don't get errors with your example. It seems that it's actually a problem with the autocomplete option. Removing autocomplete="off" from your example causes the error to occur as described.

@oyejorge
Copy link
Member

oyejorge commented Jun 1, 2021

Hmm, I just tried without autocomplete="off" and I'm still not getting the error.

@oyejorge
Copy link
Member

oyejorge commented Jun 2, 2021

Would love to get this fixed. If you have any other steps and/or clues on how to reproduce the error, please let me know.

@jsicherman
Copy link
Author

Interestingly I can't get the error log to be thrown again for some reason. However, I can still replicate the behaviour of the issue reliably.

Do the following:

  1. Type test,tes,test (or any string which contains some duplicates and some other values) followed by backspace

I've uploaded an mp4 of this happening to my Dropbox: here.

I'm trying again now and it actually occurs even with autocomplete="off" still present... Example. For some reason I can't quite isolate what's causing this.

@oyejorge
Copy link
Member

oyejorge commented Jun 2, 2021

Awesome, I see what you're talking about now. Thanks!

@jsicherman
Copy link
Author

Thanks for your quick work! Unfortunately this isn't fully fixed: Ctrl+A, backspace (or any other way of selecting multiple elements like Shift + click or Ctrl + click) still deletes elements in an unexpected manner

@oyejorge oyejorge reopened this Jun 5, 2021
@oyejorge
Copy link
Member

oyejorge commented Jun 5, 2021

Hmm.

still deletes elements in an unexpected manner

Could you describe what you mean by that? I'm not seeing any issues... wondering if your referring to the large gap that can appear between items after an item in the middle was deleted?

@jsicherman
Copy link
Author

Ah that may be my oversight. Yes upon closer inspection, it seems the elements are actually being deleted correctly, but elements right of the cursor are being pushed off to the right side of the input as you describe. Sorry for my over-eager bug reporting! I appreciate your responsiveness.

@oyejorge
Copy link
Member

oyejorge commented Jun 5, 2021

It's all good. The solution for this is the input_autogrow plugin.

@oyejorge oyejorge closed this as completed Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants