buildField method presentation ✓ 100.0%
Last updated: 2026-03-04T23:21:38.391Z
Metrics
LOC: 41
Complexity: 8
Params: 1
Coverage: 100.0% (9/9 lines, 11x executed)
Signature
buildField(wrapper: HTMLElement): : FormField
Source Code
buildField(wrapper: HTMLElement): FormField {
// Hidden input carries name + value for form submission
const hiddenInput = wrapper.querySelector<HTMLInputElement>(
":scope > input[type='hidden'], :scope > div > input[type='hidden']",
);
// Visible input: searchable react-select uses .react-select__input; non-searchable
// uses a DummyInput (inputmode="none") — both have role="combobox"
const visibleInput = wrapper.querySelector<HTMLInputElement>(
".react-select__input, input[role='combobox']",
);
const placeholder = wrapper
.querySelector<HTMLElement>(".react-select__placeholder")
?.textContent?.trim();
const isMulti =
wrapper.querySelector(".react-select__value-container--is-multi") !==
null;
// Use the visible input as the label anchor first (it likely has an id that
// a <label for="..."> points to); fall back to the hidden input or wrapper.
const labelSource = visibleInput ?? hiddenInput ?? wrapper;
const labelResult = findLabelWithStrategy(labelSource);
const field: FormField = {
element: wrapper,
selector: getUniqueSelector(wrapper),
category: "unknown",
fieldType: isMulti ? "multiselect" : "select",
adapterName: "react-select",
label: labelResult?.text,
name: hiddenInput?.name || visibleInput?.name || undefined,
id: visibleInput?.id || wrapper.id || undefined,
placeholder,
required: false,
};
field.contextSignals = buildSignals(field);
return field;
},
No outgoing dependencies.
No incoming dependencies.