Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Issue 2688073002: MD Settings: For rows containing paper-toggle-buttons, make entire row clickable. (Closed)

Created:
3 years, 10 months ago by scottchen
Modified:
3 years, 10 months ago
Reviewers:
Dan Beam, dpapad
CC:
chromium-reviews, michaelpg+watch-md-settings_chromium.org, michaelpg+watch-md-ui_chromium.org, dbeam+watch-settings_chromium.org, stevenjb+watch-md-settings_chromium.org, arv+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

MD Settings: For rows containing paper-toggle-buttons, make entire row clickable. BUG=680406 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Closing based on off-line discussion with dbeam@ and dpapad@, we're going to go with another approach with pref plus some twist (to be implemented by dbeam).

Patch Set 1 #

Total comments: 1

Patch Set 2 : convert a more complicated row #

Total comments: 8

Patch Set 3 : prevent clicking toggle from firing handler twice #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -7 lines) Patch
M chrome/browser/resources/settings/privacy_page/privacy_page.html View 1 2 3 chunks +7 lines, -4 lines 4 comments Download
M chrome/browser/resources/settings/privacy_page/privacy_page.js View 1 2 3 chunks +10 lines, -3 lines 3 comments Download

Messages

Total messages: 13 (3 generated)
scottchen
Here's the demo showing the first changed toggle working: https://drive.google.com/open?id=0ByIc0PEad7DmWndyR3dUOVAxRFU For the second changed toggle, ...
3 years, 10 months ago (2017-02-10 06:51:02 UTC) #2
scottchen
+ dbeam@ dpapad@ as reviewers.
3 years, 10 months ago (2017-02-10 06:51:40 UTC) #4
Dan Beam
https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resources/settings/privacy_page/privacy_page.html File chrome/browser/resources/settings/privacy_page/privacy_page.html (right): https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resources/settings/privacy_page/privacy_page.html#newcode108 chrome/browser/resources/settings/privacy_page/privacy_page.html:108: <div class="settings-box" on-tap="onMetricsReportingControlTap_" this changes the clickable area (compared ...
3 years, 10 months ago (2017-02-10 07:11:36 UTC) #5
Dan Beam
it's almost like i've tried this before! https://codereview.chromium.org/2684853003/#ps1
3 years, 10 months ago (2017-02-10 07:12:46 UTC) #6
scottchen
On 2017/02/10 06:51:40, scottchen wrote: > + dbeam@ dpapad@ as reviewers. Sorry, I take back ...
3 years, 10 months ago (2017-02-10 07:13:47 UTC) #7
Dan Beam
https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resources/settings/privacy_page/privacy_page.html File chrome/browser/resources/settings/privacy_page/privacy_page.html (right): https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resources/settings/privacy_page/privacy_page.html#newcode124 chrome/browser/resources/settings/privacy_page/privacy_page.html:124: on-change="onMetricsReportingControlTap_" allllso, when you tap on the toggle, you ...
3 years, 10 months ago (2017-02-10 07:14:51 UTC) #8
Dan Beam
On 2017/02/10 07:13:47, scottchen wrote: > On 2017/02/10 06:51:40, scottchen wrote: > > + dbeam@ ...
3 years, 10 months ago (2017-02-10 07:16:32 UTC) #9
scottchen
Just made one more patch, concluding at a workable solution. https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resources/settings/privacy_page/privacy_page.js File chrome/browser/resources/settings/privacy_page/privacy_page.js (right): https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resources/settings/privacy_page/privacy_page.js#newcode191 ...
3 years, 10 months ago (2017-02-10 07:53:39 UTC) #10
Dan Beam
https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resources/settings/privacy_page/privacy_page.html File chrome/browser/resources/settings/privacy_page/privacy_page.html (right): https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resources/settings/privacy_page/privacy_page.html#newcode88 chrome/browser/resources/settings/privacy_page/privacy_page.html:88: on-change="onSafeBrowsingExtendedReportingControlTap_" while your mouse is down dragging, other toggles ...
3 years, 10 months ago (2017-02-10 17:20:36 UTC) #11
scottchen
3 years, 10 months ago (2017-02-10 18:49:58 UTC) #12
https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resource...
File chrome/browser/resources/settings/privacy_page/privacy_page.html (right):

https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resource...
chrome/browser/resources/settings/privacy_page/privacy_page.html:124:
on-change="onMetricsReportingControlTap_"
On 2017/02/10 07:11:36, Dan Beam wrote:
> but when this changes, you DON'T want to invert the value (it just changed)

depends on which value. You don't wanna invert .checked, but you do wanna invert
metricsReporting_.enabled; based on my experiment, changing the checkbox value
doesn't change metricsReporting_.enabled unless the handler says to do so
(assuming checked= is one-way bounded). This is also why if you just have
on-tap, dragging doesn't work in two windows.

https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resource...
chrome/browser/resources/settings/privacy_page/privacy_page.html:124:
on-change="onMetricsReportingControlTap_"
On 2017/02/10 07:11:36, Dan Beam wrote:
> this doesn't work when you drag the toggle

on-tap doesn't fire, but on-change seems to fire when dragged.

https://codereview.chromium.org/2688073002/diff/20001/chrome/browser/resource...
chrome/browser/resources/settings/privacy_page/privacy_page.html:124:
on-change="onMetricsReportingControlTap_"
On 2017/02/10 07:14:51, Dan Beam wrote:
> allllso, when you tap on the toggle, you get double events
> 
> first, you get this change event
> 
> THEN, you get the on-tap of the parent.

Acknowledged. Fixed with a later patch.

https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resource...
File chrome/browser/resources/settings/privacy_page/privacy_page.html (right):

https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resource...
chrome/browser/resources/settings/privacy_page/privacy_page.html:88:
on-change="onSafeBrowsingExtendedReportingControlTap_"
On 2017/02/10 17:20:36, Dan Beam wrote:
> while your mouse is down dragging, other toggles change their value at each
> edge.
> 
> starting here:
> 
> 0==
> 
> grabbing the knob and moving to here without letting go
> 
> ==0
> 
> should change the effective value.  without letting go, moving between
> 
> 0==
> ==0
> 
> should continue to change the effective value.
> 
> does that work with your CL?  i'd guess not, because 'change' is only
dispatched
> at the end of this madness, whereas iron-change occurs the whole time.

it does - see https://drive.google.com/open?id=0ByIc0PEad7DmWndyR3dUOVAxRFU

https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resource...
chrome/browser/resources/settings/privacy_page/privacy_page.html:89:
on-tap="doNothing_"
On 2017/02/10 17:20:36, Dan Beam wrote:
> this is very similar to
>
https://codereview.chromium.org/2684853003/diff/20001/chrome/browser/resource...
> 
> which has a stopPropagation() branch for taps
> 
> it's a little nicer but of on-tap was ever changed to on-click on the parent
or
> on the child, this would potentially still have double events.  which is why i
> pushed them both through the same method and asserted they're the same e.type
> (event type).

I think this can be handled if we encapsulate it in a is="contained-toggle" and
just do something like...

html:
<div is=contained-toggle handler="[[onThisTriggered_]]">
    <paper-toggle-button checked="[[value]]" ...(other attr EXCEPT any on-x
handler)/>
</div>


contained-toggle.js (pseudo-code):
     var eventName = "tap"; //if you ever think we would listen to click instead
of tap
     this.root.addEventListener(eventName, handler);

     var toggle = this.root.querySelector("paper-button-toggle");
     toggle.addEventListener("change",handler);
     toggle.addEventListener(eventName, doNothing_);

I believe the above solution would solve your concern, and this'll also help us
reduce the boilerplate code we need to type up each time we want to use a
"custom toggle element".

https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resource...
File chrome/browser/resources/settings/privacy_page/privacy_page.js (right):

https://codereview.chromium.org/2688073002/diff/40001/chrome/browser/resource...
chrome/browser/resources/settings/privacy_page/privacy_page.js:150: var enabled
= !this.safeBrowsingExtendedReportingEnabled_;
On 2017/02/10 17:20:36, Dan Beam wrote:
> i still don't really understand how this works.
> 
> but on-change="onSafeBrowsingExtendedReportingControlTap_" means "hey, the
value
> just changed.  the new value is what you want".  then you invert it and send
it
> to C++.  how is this correct?

You're thinking of the toggle control's "checked" value, which does get updated
before on-change fires, but this.SBER_Enabled_ doesn't, since it's bound one-way
on the checkbox (check="[[SBER_Enabled_]]").

In other words, if there were no handlers, then when you click on the toggle,
toggle.checked would switch back and forth, but this.SBER_Enabled_ doesn't
actually change until you tell it to. And then when it does change, the toggle
will conform to it's value. This is why I'm saying it's easier to just use that
value as the source of truth as opposed to the checkbox value which might or
might not have de-synced from the value due to weird user interaction (such as
dragging not triggering event handler, etc.)

Powered by Google App Engine
This is Rietveld 408576698