Page MenuHomePhorge

AphrontFormPolicyControl: Reuse existing control ID
ClosedPublic

Authored by aklapper on Mar 21 2025, 12:20.
Tags
None
Referenced Files
F3749190: D25910.1745791787.diff
Sat, Apr 26, 22:09
F3741504: D25910.1745766264.diff
Sat, Apr 26, 15:04
F3738955: D25910.1745762526.diff
Sat, Apr 26, 14:02
F3709445: D25910.1745653214.diff
Fri, Apr 25, 07:40
F3708153: D25910.1745639959.diff
Fri, Apr 25, 03:59
F3681986: D25910.1745565939.diff
Thu, Apr 24, 07:25
F3602554: D25910.1745152516.diff
Sat, Apr 19, 12:35
F3553966: D25910.1744966220.diff
Thu, Apr 17, 08:50

Details

Summary

Do not unconditionally create a new ID which breaks the accessibility label.

Parent AphrontFormControl::render() set an ID via $this->setID(celerity_generate_unique_node_id()) and then calls $this->renderInput() on its subclass AphrontFormPolicyControl which unconditionally runs $control_id = celerity_generate_unique_node_id() to assign another ID and then does 'id' => $control_id.
This breaks accessibility (AphrontFormControl's label for="UQ0_xx" is now off by one from AphrontFormPolicyControl's a id="UQ0_xx").

Similar existing code can be found in AphrontFormTokenizerControl::renderInput() at https://we.phorge.it/source/phorge/browse/master/src/view/form/control/AphrontFormTokenizerControl.php;bccd4f5981a7e2c347e8e26cf24d8394c882724f$57-61

Closes T16019

Test Plan

Create a Maniphest Task form which exposes policy controls. Check the resulting HTML if <label for=""> and <a id=""> match.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Uhm yes thanks

There is probably a sub-bug about the inability of dropdown and tokenizers to be focused by label click, but it's unrelated to this I think. I've played with $input_id and it seems unrelated

This revision is now accepted and ready to land.Mar 22 2025, 22:33