Don't change language setting with scroll wheel #3928
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
For about 3 years now, we have had sporadic reports of the CKAN GUI using an unexpected language, initially Chinese, later French, occasionally other languages.
Cause
Extensive, repeated audits of the code in search of bugs turned up a few leads that ultimately were dead ends. The code for defaulting the language initially, saving to/loading from disk, and the settings dialog are about as simple and robust as could be hoped, and we were not able to reproduce the problem with any imagined set of steps.
However, today a user shared a video that might explain what has been happening:
If the user thinks the dialog may be scrollable (many modern UIs hide the scrollbar until scrolling happens 😵💫), they may flick the mouse wheel to try to expose more settings. If the mouse cursor happens to be hovering over the language dropdown (a rare coincidence to be sure, but the reports of the problem have also been pretty rare), this changes its value, even without clicking it. This is the default behavior of comboboxes in WinForms, but it's unhelpful and surprising in this case.
Changes
Now this dropdown has a handler for the
MouseWheel
event, which casts itsMouseEventArgs
argument toHandledMouseEventArgs
in order to setHandled = true
, which prevents the control from reacting to the mouse wheel. Appropriately, users will have to click to change the setting.Yes, this is the documented way to access this API (!!):
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.handledmouseeventargs?view=windowsdesktop-7.0#remarks
Fixes #3244. (Probably? We'll see if anyone reports it again after this fix goes public.)