@jsenv/navi 0.29.381 → 0.29.382

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40917,6 +40917,11 @@ const uiStateHoldsNothing = (uiState) => {
40917
40917
  */
40918
40918
  const NO_ACTION_YET = Symbol("no_action_yet");
40919
40919
 
40920
+ // The control types rendered as an element `<label for>` can name: HTML's
40921
+ // labelable elements are button, input, select, textarea, output, meter and
40922
+ // progress — a picker's trigger is one of them, a link or a details is not.
40923
+ const CONTROL_TYPES_A_LABEL_CAN_POINT_AT = new Set(["button", "input", "select", "picker"]);
40924
+
40920
40925
  // Resets field-specific contexts so nested fields inside this component
40921
40926
  // don't inherit the current field's id, message props, or interface reporting.
40922
40927
  // Sets ParentUIStateControllerContext to the leaf's own uiStateController so
@@ -41014,8 +41019,13 @@ const useControlProps = (props, {
41014
41019
  standalone
41015
41020
  } = props;
41016
41021
  const idDefault = useId();
41017
- const controlId = useContext(ControlIdContext);
41018
- props.id = props.id || controlId || idDefault;
41022
+ // A Field's id is what its Label points at, so only a control a label can
41023
+ // point at (see the set) takes it. A link in the label's own text is a
41024
+ // control too, but never that target: taking the id would make two elements
41025
+ // answer for it, and the label would read the link's state as its control's.
41026
+ const fieldId = useContext(ControlIdContext);
41027
+ const labelable = CONTROL_TYPES_A_LABEL_CAN_POINT_AT.has(controlType);
41028
+ props.id = props.id || (labelable ? fieldId : undefined) || idDefault;
41019
41029
  const controlName = useContext(ControlNameContext);
41020
41030
  props.name = props.name || controlName;
41021
41031
  const isCheckable = isCheckableInput(controlType, props.type);