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)

graph LR extractDropdownOptions["extractDropdownOptions"] buildField["buildField"] buildField -->|calls| extractDropdownOptions style extractDropdownOptions fill:#dbeafe,stroke:#2563eb,stroke-width:2px click extractDropdownOptions "591c745dfe181710.html" click buildField "455296e8c1fe68f0.html"
SourceType
buildField calls