Fix: Radio focus handler bound to onChange instead of onFocus#5468
Open
TranscenderNing wants to merge 116 commits into
Open
Fix: Radio focus handler bound to onChange instead of onFocus#5468TranscenderNing wants to merge 116 commits into
TranscenderNing wants to merge 116 commits into
Conversation
* Fixes element.MaterialRadio.[un]check() calls on radio lists
This commit adds an [Issue Template](https://github.com/blog/2111-issue-and-pull-request-templates) to this repo alerting users to the status of features / breaking 1.x changes by the core team, as well as bug reporting guidelines. This will hopefully help stabilize the work being done for google#4462
…plate Add issue template outlining feature request / bug reporting guidelines
Update acorn to version 3.3.0 🚀
….0.0 Update gulp-connect to version 5.0.0 🚀
Update gulp-uglify to version 2.0.0 🚀
Update mocha to version 3.0.0 🚀
Update mocha to version 3.0.2 🚀
….3.1 Update gulp-flatten to version 0.3.1 🚀
Update dependencies
_radio.scss: scale() instead of scale3d()
Since we're unsure of what this value should be and it has existed this long, simply removing and not making valid as to try and not break existing applications.
* Fix google#1335, Reverse google#311 * Fix google#1335, Reverse google#311
When using "background" property CSSO not working correctly ( if not replacing sass property ). Separating "background" to "background-color" and "background-image" solve this problem
Uncheck the main checkbox when unchecking a checkbox if is checked
Thanks for your comments. I hope that this solution seems to you better
Correction of syntax
Fixed typo
set is_dirty when placeholder exists
In MaterialRadio.prototype.init() (line 230), boundFocusHandler_ was incorrectly bound to this.onChange_ instead of this.onFocus_. This caused every focus event on a radio button (e.g. via Tab key) to trigger the change handler logic, which performs an O(n) scan of ALL radio buttons in the DOM via document.getElementsByClassName. Impact: - Wrong behavior: Focus triggers change-handler logic meant only for actual value changes, causing potential visual state glitches - Performance: Every focus event triggers a full DOM query + iteration over all radio buttons on the page Root cause: This appears to be a copy-paste error from line 229 where boundChangeHandler_ is correctly bound to onChange_. The same pattern is correctly implemented in checkbox.js (line 251) and switch.js (line 252). Fix: Change .onChange_ to .onFocus_ on line 230 (single word change).
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
MaterialRadio.prototype.init()line 230:boundFocusHandler_was incorrectly bound tothis.onChange_instead ofthis.onFocus_.onChange_→.onFocus_Root Cause Analysis
In
src/radio/radio.jsline 230:This is a clear copy-paste error from line 229, where
boundChangeHandler_is correctly bound toonChange_. The same pattern is correctly implemented in sibling components:checkbox.jsline 251:this.boundFocusHandler_ = this.onFocus_.bind(this);switch.jsline 252:this.boundFocusHandler_ = this.onFocus_.bind(this);radio.jsline 230:❌this.boundFocusHandler_ = this.onChange_.bind(this);Reproduction Steps
onChange_which does a full DOM query viadocument.getElementsByClassName()and callsupdateClasses_()on every radio button on the pageonFocus_handlerTest Plan
onFocus_method exists at line 97 of radio.jsAdditional Context
This was found during a systematic code audit comparing event handler initialization across all MDL form components. All three primary form components (checkbox, radio, switch) share nearly identical initialization patterns, making this inconsistency easy to spot.