Skip to content

Commit b1de960

Browse files
authored
Merge pull request #508 from mashmatrix/support-legacy-environments-without-css-escape
2 parents 020bbd6 + a83ee47 commit b1de960

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/scripts/Lookup.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,14 @@ const LookupScopeSelector: FC<LookupScopeSelectorProps> = ({
270270
return;
271271
}
272272

273-
const targetElement = scopeDropdown.querySelector(
274-
`#${CSS.escape(getScopeOptionId(nextFocusedIndex))}`
273+
const targetElement = document.getElementById(
274+
getScopeOptionId(nextFocusedIndex)
275275
);
276276

277-
if (!(targetElement instanceof HTMLElement)) {
277+
if (
278+
!(targetElement instanceof HTMLElement) ||
279+
!scopeDropdown.contains(targetElement)
280+
) {
278281
return;
279282
}
280283

@@ -1118,12 +1121,15 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
11181121
return;
11191122
}
11201123

1121-
const dropdownContainer = dropdownElRef.current;
1122-
const targetElement = dropdownContainer.querySelector(
1123-
`#${CSS.escape(getOptionId(nextFocusedValue))}`
1124+
const targetElement = document.getElementById(
1125+
getOptionId(nextFocusedValue)
11241126
);
11251127

1126-
if (!(targetElement instanceof HTMLElement)) {
1128+
const dropdownContainer = dropdownElRef.current;
1129+
if (
1130+
!(targetElement instanceof HTMLElement) ||
1131+
!dropdownContainer.contains(targetElement)
1132+
) {
11271133
return;
11281134
}
11291135

src/scripts/Picklist.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,15 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
308308
return;
309309
}
310310

311-
const dropdownContainer = dropdownElRef.current;
312-
const targetElement = dropdownContainer.querySelector(
313-
`#${CSS.escape(`${optionIdPrefix}-${nextFocusedValue}`)}`
311+
const targetElement = document.getElementById(
312+
`${optionIdPrefix}-${nextFocusedValue}`
314313
);
315314

316-
if (!(targetElement instanceof HTMLElement)) {
315+
const dropdownContainer = dropdownElRef.current;
316+
if (
317+
!(targetElement instanceof HTMLElement) ||
318+
!dropdownContainer.contains(targetElement)
319+
) {
317320
return;
318321
}
319322

0 commit comments

Comments
 (0)