-
Notifications
You must be signed in to change notification settings - Fork 62
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
add instance.getValue() and instance.setValue(newVal) #88
base: master
Are you sure you want to change the base?
Conversation
//-- regular select newVal = 'foo'; //-- selected foo and bar option for multiple newVal = ['foo','bar']; currentVal = getValue() //-- currentVal is Array like ['foo','bar'] or ['boo'] for multiple select //-- currentVal is string if not multiple
Reviewer's Guide by SourceryThis pull request introduces two new methods, setValue and getValue, to the NiceSelect class. The setValue method allows for programmatically setting the value of the select element, while the getValue method retrieves the current value. Additionally, the handling of selected options has been improved in the _onItemClicked and resetSelectValue methods to ensure more robust manipulation of the 'selected' attribute. File-Level Changes
Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @amlan-sw - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using opt.selected = false instead of delete(opt.selected) for better readability and consistency with common JavaScript practices.
- The setValue() method is quite complex, especially for handling multiple selects. Consider refactoring it into smaller, more focused functions to improve readability and maintainability.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
instance.setValue(newVal)
source SELECT tag will also change its value and highlight following newVal
currentVal = instance.getValue()
Summary by Sourcery
Add methods to set and get the value of the select element, enhancing the functionality to support both single and multiple selections.
New Features: