Design issue Toggle script quirks

Lukas W.

Well-known member
Affected version
2.0.10
There appears to be a few quirks in the toggle script that cause somewhat unexpected/confusing behavior in certain occasions. Specifically, this is reproducible on the ACP style page.

Specific issues:
  1. Toggling the default style off will throw an error message "It is not possible to prevent users from selecting the default style."
    • However, the off switch will not toggled back on again
  2. Switching the default theme to a style that's deactivated triggers the same error, but the state of the toggle is also kept.
  3. Refreshing the page resets both of these changes, so the page is left in an inconsistent state.
  4. Now toggling of the default theme again, then change the default theme trigger to an active theme, will again trigger the error message "It is not possible to prevent users from selecting the default style.", this time wrongly, as I've just set it to be an active theme. Reloading the page will reset the the off switch for the default theme, but keep the default toggle with the new selection. I assume it tried to toggle off the previous default theme again before changing the new default theme.

Small illustrating video on the matter:
https://gfycat.com/ForsakenSelfassuredAsiantrumpetfish
 
I've reproduced the issue, though I don't think we're going to take any steps to attempt to address it at this time. It's quite devious. For reference though, roughly, the same issue has existed all the way back to XF1 (I think an early version of it, if not 1.0) and I don't believe we've had any significant issues from it.

The primary issue is that these are basically just regular form components, but with a little bit of JS that auto submits the form when you click on them. The form handing is our standard ajax form handler. The error happens and normally you'd just fix the form and resubmit. What you see on the screen is consistent in that it's explaining the desired state, though the error does invalidate a bit of an assumption made by the code.

Realistically, I think resolving this would require tracking the state of the form so we can revert it to the last known successful state if we get an error. Note that this isn't just resetting the form, as you could make a valid action and then an invalid one and resetting it would end up being worse. Otherwise, it'd end up being a very different approach for this sort of thing. That could be viable, though given the length of time this has been around and the general triviality of resolving it (by re-enabling a style or changing the default or refreshing the page), it doesn't seem worth it at this time.
 
Back
Top Bottom