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 scrollAfterSelect as a configurable option for multiselect dropdowns to allow toggling of highlightFirstItem() behaviour #5150
Conversation
Nice! Can you add some tests for this? |
@alexweissman I added some tests to focusing-tests.js to verify the configurable option behaviour. I also changed the default for scrollAfterSelect to be "true" to avoid modifying existing implementations (this was debatable to me since it means that anyone using a non-paginating dropdown will need to explicitly set { scrollAfterSelect: false} but I feel it's justifiable to avoid introducing breaking changes for pagination users). |
I have to say though, I am confused by the explanation given here: #4417 (comment) @jgbishop and @AlexanderLeonov, can you explain exactly why the |
Any update on this PR ? I'm using large multi-select with only few value to select and this bug/feature is very annoying for users :/ I'm trying to do a monkey patching for disabling highlightFirstItem() function but I can't find the correct syntax / path ... |
Sorry if this is spamming but I was wondering what the progress of this PR for acceptance is. |
@kevin-brown @alexweissman Is this PR ready for merge? If so, merge it, please! |
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.
@boweihan in my tests I saw that it was necessary to add 'scrollAfterSelect' validation in calls to 'highlightFirstItem()' also in the file 'dist\js\select2.js'
@marciojesus Would that not be done during a build phase? |
@jsJunky I don't understand your question very well. But what I meant is that only worked for me when I added of 'scrollAfterSelect' validation in call of 'highlightFirstItem()' in the the file 'dist\js\select2.js' unlike of 'src/js/select2/results.js' :) |
@marciojesus Usually most projects do not require you to manually update the final built files. Those will be handled by the build system that will grab all necessary files and build them into a file in the |
Any update on this? |
Is there an update on this? Really looking forward to this being fixed? |
Following modification on select2.js helped for now
|
Let me know if there's anything I can do to help push this through! |
@kevin-brown @alexweissman Any news? |
I have several projects where a monkeypatch is active untill this is released. Is there any estimate on when this will be released? Is there anything I can help with to get this released? |
@dinandmentink I've created a fork of select2 with some monkeypatches of community. See the repo: https://github.com/pedrofurtado/select2 See also the diff: develop...pedrofurtado:develop |
@dinandmentink Test using this fork to check if the issues are resolved, at least until a new official version is released. I'm using this version in my company's projects. In your {
"dependencies": {
"select2": "https://github.com/pedrofurtado/select2#develop"
}
} |
@boweihan I added some docs explaining this new property ( select2/docs@165f945 ). |
I get following error, when I use the 'develop' version (instead of 4.05): This code causes the error Do I need to configure select2 to make this version work? |
@arning The |
@pedrofurtado |
…wns to allow toggling of highlightFirstItem() behaviour (select2#5150) * Add scrollOnSelect as a configurable option * default scrollOnSelect to true to avoid modifying existing behaviour * added tests and default option for scrollAfterSelect
Cheers this is exactly what I needed. May I point out that you say the configurable option is "scrollOnSelect" while the code you changed in the js is "scrollAfterSelect". |
Resolves issue for multiselects using closeOnSelect: false that caused the list of results to scroll to the first selection after each select/unselect. This behaviour was intentional to deal with infinite scroll UI issues but it created an issue with multiselect dropdown boxes of fixed length. This pull request adds a configurable option to toggle between these two desirable behaviours.
This pull request includes a
The following changes were made
I ran into this issue when implementing select2 multiselect dropdowns with a fixed item length. It was confusing to have the focus move to the first item after each select/unselect event.
If this is related to an existing ticket, include a link to it as well.
#4869 - is tagged needs more work. I noticed it hasn't been touched for a while so I'm following up on this.
#4417 - discussion for where this problem originated. (this particular commit - 9f58128)