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

Advanced Select removeOption doesn't work after update #417

Closed
umaraziz0 opened this issue Jul 31, 2024 · 5 comments
Closed

Advanced Select removeOption doesn't work after update #417

umaraziz0 opened this issue Jul 31, 2024 · 5 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@umaraziz0
Copy link

umaraziz0 commented Jul 31, 2024

Summary

Advanced Select add & remove options don't work after update

Steps to Reproduce

Tried using the example component in the docs

  1. Click "Add Three Options" button
  2. Click "Remove values 5,6,7" button
  3. View console for error

Demo Link

https://preline.co/docs/advanced-select.html#add-remove-options

Expected Behavior

  • The removeOption should work as intended.
  • No console.log messages should be shown, especially in production.

Actual Behavior

  • console.log messages are shown, seems to be and the affected option's val values and false
  • The console throws an error: Uncaught TypeError: Cannot read properties of null (reading 'length') and doesn't do anything else.

Seems to occur in single select dropdowns, the multiple select example in the docs has no issue.

This also happens in one of my projects, when I tried upgrading the package version due to this bug: #414 , where in my case no items are removed.

Preline version: ^2.4.1
Chrome version: Version 126.0.6478.185 (Official Build) (arm64)

Screenshots

image

@umaraziz0 umaraziz0 changed the title Advanced Select add & remove options don't work after update Advanced Select removeOption don't work after update Jul 31, 2024
@umaraziz0 umaraziz0 changed the title Advanced Select removeOption don't work after update Advanced Select removeOption doesn't work after update Jul 31, 2024
@olegpix
Copy link
Collaborator

olegpix commented Jul 31, 2024

@umaraziz0 Hi,
Thank you for bringing this to our attention, we're appreciate it!
As far as I can see this error doesn't affect functionality and you can continue to use this functionality despite the error in the console.
We will fix this in the next update.
Best regards!

@jahaganiev jahaganiev added bug Something isn't working enhancement New feature or request labels Aug 5, 2024
@ihorshto
Copy link

Have the same probleme!
Preline version: 2.4.1

@ihorshto
Copy link

ihorshto commented Sep 19, 2024

Find a solution to this problem by using try catch construct. So in catch we can handle errors and in finally continue executing the code!

        const endMinutesSelect = HSSelect.getInstance('#minutesEnd');

           try {
                endMinutesSelect.removeOption(optionsToDelete)
            } catch (error) {
               
            } finally {
                endMinutesSelect.addOption(newOptions);
            }

@jahaganiev
Copy link
Member

Hey @umaraziz0 - please check the latest version, the issue has been fixed. Thanks!

@krishnaguragain
Copy link

How to remove all the select options?

Need to remove select options without knowing the keys as options are remotely fetched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants