User tests: Successful: Unsuccessful:
Pull Request for Issue #20853 .
Make it possible to use "onchange" events for switcher fields (type="radio", class="switcher").
There was once opened issue #20853 for "onchange" and "onclick" events, which was closed because PR #20931 was made for the CMS.
This PR then was closed because a PR against the backend template repo was made: joomla/40-backend-template#446.
This then was merged into the backend template but either never found the way to the CMS or was later removed by some other change.
This PR here brings the correction back, but only for "onchange", not for "onclick", because to click on a switcher always means to change the value, and because we also don't have the "onclick" event on list fields.
The change does it in a bit different way than #20931 and joomla/40-backend-template#446, so it is closer to the existing implementation in other field layouts.
In addition to the "onchange" property, this PR also adds the "id" property.
Make sure that your web browser allows popup alerts for your Joomla backend.
Edit some form XML and add an onchange event to a switcher field.
E.g. you can edit file "administrator/components/com_config/forms/application.xml" and modify field name="gzip" by adding an "onchange" property for a javascript alert as follows:
<field
name="gzip"
type="radio"
label="COM_CONFIG_FIELD_GZIP_COMPRESSION_LABEL"
class="switcher"
default="0"
filter="boolean"
onchange="alert('Hello, I am a switcher field.')"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
Go to a page where you can see the switcher field modified in step 2 and toggle the field.
E.g. if you used the field suggested in step 2: Go to the "Server" tab of "Global Configuration" in backend and toggle the "Gzip Page Compression" switcher field.
Result: No browser alert, see section "Actual result" below..
In developer tools of your web browser, inspect html of the switcher element ("fieldset" html element).
Result: No "onchange" property added to fieldset, see section "Actual result" below.
Apply the patch of this PR.
Go to some other page and then back, e.g. if you used "Global Configuration" close it and then open it again, and toggle the switcher field.
Result: See section "Expected result" below.
In developer tools of your web browser, inspect html of the switcher element ("fieldset" html element).
Result: See section "Expected result" below.
Onchange event works:
Fieldset has "id" and "onchange" properties:
Onchange event doesn't work.
Fieldset doesn't have "id" and "onchange" properties:
Not sure. Maybe some doc about fields tells onchange is not supported for switchers?
Status | New | ⇒ | Pending |
Category | ⇒ | Layout |
Labels |
Added:
?
|
@brianteeman I'd be happy if you could find some time for testing this. It's an easy test for a small change.
I have tested this item
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-12-30 11:40:28 |
Closed_By | ⇒ | HLeithner |
Quy test is valid and merge by code review
Thanks
Thanks too to testers and mergers ;-)
Drone failure seems to be the usual, randomly occurring timeout on mysql system tests and so not to be related to this PR.