Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

fix(ripple): Ripple should not activate on disabled label click #532

Merged
merged 6 commits into from
May 10, 2017

Conversation

amsheehan
Copy link
Contributor

resolves #377

@amsheehan amsheehan requested a review from traviskaufman April 19, 2017 13:43
@codecov-io
Copy link

codecov-io commented Apr 19, 2017

Codecov Report

Merging #532 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #532      +/-   ##
=========================================
+ Coverage    99.9%   99.9%   +<.01%     
=========================================
  Files          53      53              
  Lines        2217    2221       +4     
  Branches      265     266       +1     
=========================================
+ Hits         2215    2219       +4     
  Misses          2       2
Impacted Files Coverage Δ
packages/mdc-ripple/foundation.js 100% <100%> (ø) ⬆️
packages/mdc-ripple/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 248734e...9dea2f6. Read the comment docs.

@amsheehan amsheehan requested review from yeelan0319 and removed request for traviskaufman April 19, 2017 14:14
Copy link
Contributor

@traviskaufman traviskaufman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this decreases coverage on a bunch of our files. I think more tests are needed here for the ripple foundation logic as well as making sure in the checkbox/radio components that clicking on a disabled checkbox/radio will not cause the ripple activation classes to be added.

@@ -64,6 +64,7 @@ export class MDCCheckbox extends MDCComponent {

getDefaultFoundation() {
return new MDCCheckboxFoundation({
shouldIgnoreRippleActivation: () => this.disabled,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm....I'm thinking that isSurfaceDisabled or isSurfaceInteractive might be a better method name here.

With shouldIngoreRippleActivation, that kind of leaves the heuristics of when a ripple should not be triggered up to the implementor. I'm unsure if this is what we should be going for. Instead, we should encode the heuristics of when the ripple should be activated into the foundation itself (e.g. when isSurfaceActive is false and we encounter a keyboard event, we don't enable the ripple).

@@ -137,6 +137,8 @@ Since MDC Radio is primarily driven by its native control, the adapter API is ex
| `addClass(className: string) => void` | Adds a class to the root element. |
| `removeClass(className: string) => void` | Removes a class from the root element. |

> **NOTE**: There are some cases where we do not want ripples to activate. Most of this logic is handled by native control attributes such as `disabled` on input fields. One caveat is that ripples will activate on disabled elements if their corresponding `label` element is clicked. For this, we override the ripple's `shouldIgnoreRippleActivation()` adapter method in `mdc-radio`'s `getDefaultFoundation()`, and check if the control is disabled before activating the ripple.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for including this note here? Seems out of context with the rest of the README. If this is advice for how framework implementors can deal with configuring the ripple properly, we may want to give more background on that and also mention this within the mdc-checkbox README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually is no longer applicable. The latest code keeps all of this logic in mdc-ripple, whose README documents the behavior.

@amsheehan amsheehan force-pushed the fix/ripple-fires-on-disabled branch from 03cb094 to 92677e6 Compare May 9, 2017 17:50
@amsheehan amsheehan force-pushed the fix/ripple-fires-on-disabled branch from 92677e6 to 4d68e60 Compare May 9, 2017 18:14
Copy link
Contributor

@yeelan0319 yeelan0319 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMed!

@amsheehan amsheehan dismissed traviskaufman’s stale review May 9, 2017 19:59

because yiran said go for it

@amsheehan amsheehan merged commit 7cc3dc8 into master May 10, 2017
@amsheehan amsheehan deleted the fix/ripple-fires-on-disabled branch May 10, 2017 18:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabled radio fires ripple when corresponding label is clicked
4 participants