Page MenuHomePhabricator

Use meaningful identifiers for fields in ProtectionForm to allow CSS styling
Open, Needs TriagePublic

Description

Following T274934 and especially my comment about meaningful identifiers, would it be possible to use meaningful identifiers for fields in ProtectionForm to allow CSS styling. Currently, identifiers seems to be auto-generated and auto-numbered making it difficult to apply CSS styling on them (which resulted in the problem reported in T274934 when the same identifier started having a new meaning).

For example, currently, the checkbox for cascade protection is identified as ooui-php-18. Applying a CSS rule on such identifier will cause problems in the long term. So, is it possible to have meaningful and stable identifiers for main fields?

For the moment, we resorted to selectors like .mw-htmlform-field-HTMLCheckField[data-ooui*='{"tag":"mwProtect-cascade"}'] in MediaWiki:Group-sysop.css to be able to select the field.

Event Timeline

You can use the name of the checkbox, so document.getElementsByName('mwProtect-cascade')[0]

That being said, this basically happens every time a form gets converted to ooui, and is a real pain for continuity or scripts/gadgets.

You can use the name of the checkbox, so document.getElementsByName('mwProtect-cascade')[0]

That being said, this basically happens every time a form gets converted to ooui, and is a real pain for continuity or scripts/gadgets.

For CSS, you can select the parent that has the id and then the input itself using mwProtect-cascade# > input, but the issue is you can't use id or name to select the field layout that both the checkbox and its label are in.