extractDropdownOptions function infrastructure ✓ 100.0%
Last updated: 2026-03-04T23:21:38.386Z
Metrics
LOC: 25
Complexity: 7
Params: 2
Coverage: 100.0% (4/4 lines, 0x executed)
Signature
extractDropdownOptions(
wrapper: HTMLElement,
): : Array<{ value: string; text: string }> | undefined
Source Code
function extractDropdownOptions(
wrapper: HTMLElement,
): Array<{ value: string; text: string }> | undefined {
// Antd renders options in a portal — try to find them via the dropdown ID
const listboxId = wrapper
.querySelector<HTMLElement>("[role='combobox']")
?.getAttribute("aria-controls");
if (listboxId) {
const listbox = document.getElementById(listboxId);
if (listbox) {
const items = listbox.querySelectorAll<HTMLElement>("[role='option']");
const opts = Array.from(items)
.map((item) => ({
value: item.getAttribute("title") ?? item.textContent?.trim() ?? "",
text: item.textContent?.trim() ?? "",
}))
.filter((o) => o.value);
if (opts.length > 0) return opts;
}
}
return undefined;
}
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| buildField | calls |