Page MenuHomePhabricator

Global preferences opt-out checkboxes should inherit the hide-if setting of the preference
Closed, ResolvedPublic5 Estimated Story PointsBUG REPORT

Assigned To
Authored By
Tgr
Oct 24 2021, 1:18 AM
Referenced Files
F34909541: Screen Shot 2022-01-05 at 5.12.50 PM.png
Jan 6 2022, 7:06 PM
F34909540: Screen Shot 2022-01-05 at 5.15.24 PM.png
Jan 6 2022, 7:06 PM
F34909579: Screen Shot 2022-01-06 at 2.04.09 PM.png
Jan 6 2022, 7:06 PM
F34877192: T294186_step7.png
Dec 10 2021, 3:43 PM
F34877186: T294186_step3.png
Dec 10 2021, 3:43 PM
F34877184: T294186_step2.png
Dec 10 2021, 3:43 PM
F34877197: T294186_step8.png
Dec 10 2021, 3:43 PM
F34877188: T294186_step4.png
Dec 10 2021, 3:43 PM

Description

An example of two user preferences, with the second having a hide-if dependency on the first (ie. the second gets hidden if the first is unchecked):

hideif1.png (174×480 px, 25 KB)
hideif2.png (140×372 px, 19 KB)

The local exception checkbox should also get hidden.

(The example is the growthexperiments-homepage-enable and growthexperiments-homepage-pt-link preferences from the GrowthExperiments extension, from the bottom of https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-personal .)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
ldelench_wmf set the point value for this task to 3.Oct 27 2021, 12:15 PM
ldelench_wmf moved this task from Needs Discussion to Up Next (June 3-21) on the Community-Tech board.

Another example when you change from Vector to another skin:

vector_example_before.png (643×960 px, 95 KB)

vector_example.png (556×972 px, 78 KB)

Change 742569 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/GlobalPreferences@master] Make local exception checkbox inherit 'hide-if' setting

https://gerrit.wikimedia.org/r/742569

Change 742569 merged by jenkins-bot:

[mediawiki/extensions/GlobalPreferences@master] Make local exception checkbox inherit 'hide-if' setting

https://gerrit.wikimedia.org/r/742569

@MusikAnimal I am sometimes finding the state after I "unhide" an option to be incorrect.

For example:

  1. Set the local-exception on both "Display newcomer homepage" and "Default to newcomer homepage from username link in personal tools"
    disabled_before.png (196×661 px, 21 KB)
  2. Uncheck "Display newcomer homepage"
    disabled_during.png (120×572 px, 10 KB)
  3. Check it again
    disabled_after.png (182×629 px, 21 KB)

The local option for "Default to newcomer homepage from username link in personal tools" is disabled when it should not be.

I have also found circumstances where the option is enabled when the local-exception is unchecked.

However, I cannot always reproduce this, making me think it is another GlobalPreferences/Special:Preferences client-side caching bug. So it might not be related to anything we have done.

@MusikAnimal I am sometimes finding the state after I "unhide" an option to be incorrect.

For example:

  1. Set the local-exception on both "Display newcomer homepage" and "Default to newcomer homepage from username link in personal tools" F34796236
  2. Uncheck "Display newcomer homepage" F34796238
  3. Check it again F34796240

The local option for "Default to newcomer homepage from username link in personal tools" is disabled when it should not be.

I have also found circumstances where the option is enabled when the local-exception is unchecked.

However, I cannot always reproduce this, making me think it is another GlobalPreferences/Special:Preferences client-side caching bug. So it might not be related to anything we have done.

First off, disregard what I said during the RTL meeting. I'm able to test saving these preferences on my local without the more complicated steps in installing Growth Experiments.

That said, I can't reproduce this issue on my local or on beta. Perhaps it was a caching issue, as you say? In step 3, I see that the "Default to newcomer homepage from username link in personal tools" is disabled, but it correctly re-enables once I tick the local exception checkbox. I've tested in Firefox and Chrome. I also tested both with and without saving after step 2, as I wasn't sure if you were referring to a JavaScript issue. If it wasn't clear, I believe it's expected behaviour for the previous values of dependent checkboxes to be reset after saving. For instance, in step 3 I observe the disabled "Default to newcomer homepage…" checkbox because the local exception value was reset after unchecked the dependent "Display newcomer homepage" and saved.

Could you maybe try to repro once more? Even a video might help, as I might be doing something wrong in my attempt to repro. Thanks for your detailed QA pass, as always!

An unrelated issue that I can reproduce is that in step 1, the text for the "Display newcomer homepage" option is grayed out as if it is disabled, even though it's not. That seems to be unique to this specific preference.

I can reproduce on beta enwiki.

  • add both settings to global preferences (enabled)
  • check both exception buttons locally
  • uncheck "Display newcomer homepage"
  • re-check "Display newcomer homepage"

"Default to newcomer homepage..." will come back greyed out.

This is somewhat normal: the hide-if logic both hides and disables the control; it just doesn't clean up disabled state correctly. I think it's buggy and never unsets $elOrLayout.wasDisabled and that's what causes the issue. Not sure why that only triggers when global preferences are involved.

Ah, I can repro now! Here's the steps I had to take:

  1. Enable both global settings
  2. Set a local exception for "Display newcomer homepage" with the override value being OFF (unchecked)
  3. Save
  4. Enable the "Display newcomer homepage" local exception
  5. Check the local exception checkbox for "Default to newcomer homepage…"
  6. Uncheck "Display newcomer homepage"
  7. Re-enable "Display newcomer homepage"

The only time I saved the form was step 3.

This is somewhat normal: the hide-if logic both hides and disables the control; it just doesn't clean up disabled state correctly. I think it's buggy and never unsets $elOrLayout.wasDisabled and that's what causes the issue. Not sure why that only triggers when global preferences are involved.

Thanks! This is helpful :) I'm looking more into it now.

NRodriguez changed the point value for this task from 3 to 5.Dec 2 2021, 6:07 PM

So, we think that changing the code to use $elOrLayout.fieldWidget.wasDisabled should fix this issue. The reason is that this property is set and updated in setDeleted(), which means it keeps track of state changes, whereas the wasDeleted property set in the hide-if logic is never updated. I think this change is correct, since the two properties should in theory always have the same value, but would like to confirm that. @matmarex I see you wrote this code a few years ago. Do you by any chance remember if there was a particular reason not to use the wasDisabled property of the inner widget?

QA Notes:
Reproduction steps for the original bug:

  1. Go to https://en.wikipedia.beta.wmflabs.org/wiki/Special:GlobalPreferences
  2. Check the left-most checkbox next to the option labelled Display newcomer homepage
    T294186_step2.png (834×975 px, 100 KB)
  3. Check the checkbox just to the right of this
    T294186_step3.png (865×966 px, 103 KB)
  4. Check the checkbox left-most checkbox next to the option labelled Default to newcomer homepage from username link in personal tools
    T294186_step4.png (873×953 px, 103 KB)
  5. Click Save
  6. Go to https://en.wikipedia.beta.wmflabs.org/wiki/Special:Preferences
  7. Underneath Display newcomer homepage check Set a local exception for this global preference
    T294186_step7.png (866×951 px, 111 KB)
  8. Uncheck Display newcomer homepage
    T294186_step8.png (863×920 px, 115 KB)

The outcome should be what is displayed in the last screenshot. The option labelled Default to newcomer homepage from username link in personal tools should disappear, as well as the local exception checkbox for that option.

For the follow up bug, reproduction steps can be found in T294186#7538001 and T294186#7544057.

So, we think that changing the code to use $elOrLayout.fieldWidget.wasDisabled should fix this issue. The reason is that this property is set and updated in setDeleted(), which means it keeps track of state changes, whereas the wasDeleted property set in the hide-if logic is never updated. I think this change is correct, since the two properties should in theory always have the same value, but would like to confirm that. @matmarex I see you wrote this code a few years ago. Do you by any chance remember if there was a particular reason not to use the wasDisabled property of the inner widget?

Hi, did you try to use the wasDisabled property? It seems just an internal temporary var and not in semantics "state right before we call the setDisabled() last time" which we want.
It always equal to the return value of isDisable() after setDisabled().

Since the initial state of non-global preferences is not being disabled from the server-side per Gerrit change 737702, I can't reproduce the follow-up bugs by the given steps.

Confirmed that the inherit the hide-if setting of the preference is working as expected.

The local option for "Default to newcomer homepage from username link in personal tools" is not disabled as it should be

Screen Shot 2022-01-05 at 5.15.24 PM.png (1×1 px, 267 KB)

The option labelled Default to newcomer homepage from username link in personal disappear, as well as the local exception checkbox for that option.

Screen Shot 2022-01-05 at 5.12.50 PM.png (1×2 px, 335 KB)

@MusikAnimal Question: the newcomer homepage did not load on the home page when checked, I was hoping to see a difference on the home page. Is that as expected since it is Beta? Anyhow, I did see a change on the user preference page when I check newcomer homepage, from user preference link.

On this url: https://en.wikipedia.beta.wmflabs.org/wiki/Special:Preferences
"Display newcomer homepage" is grayed out when "Set a local exception for this global preference." was unchecked.
That might be by design, I am not certain. see screen shot below:

Screen Shot 2022-01-06 at 2.04.09 PM.png (1×2 px, 260 KB)