Skip to content

Commit 65b5a20

Browse files
committed
extension: Improve label discovery in getElement
1 parent f1aa35e commit 65b5a20

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

web/packages/extension/src/common.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ class SelectOption implements OptionElement<string | null> {
111111
}
112112

113113
function getElement(option: Element): OptionElement<unknown> {
114-
const label = option.getElementsByTagName("label")[0]!;
114+
const element = option.querySelector<HTMLInputElement | HTMLSelectElement>(
115+
"input, select",
116+
)!;
117+
118+
const label = option.querySelector<HTMLLabelElement>(
119+
`label[for="${element.id}"]`,
120+
)!;
115121

116122
const [input] = option.getElementsByTagName("input");
117123
if (input) {

0 commit comments

Comments
 (0)