Skip to content

Commit a83ee47

Browse files
(Picklist, Lookup): refactor to combine conditions
1 parent 2b51c1e commit a83ee47

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/scripts/Lookup.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,10 @@ const LookupScopeSelector: FC<LookupScopeSelectorProps> = ({
274274
getScopeOptionId(nextFocusedIndex)
275275
);
276276

277-
if (!(targetElement instanceof HTMLElement)) {
278-
return;
279-
}
280-
281-
if (!scopeDropdown.contains(targetElement)) {
277+
if (
278+
!(targetElement instanceof HTMLElement) ||
279+
!scopeDropdown.contains(targetElement)
280+
) {
282281
return;
283282
}
284283

@@ -1126,12 +1125,11 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
11261125
getOptionId(nextFocusedValue)
11271126
);
11281127

1129-
if (!(targetElement instanceof HTMLElement)) {
1130-
return;
1131-
}
1132-
11331128
const dropdownContainer = dropdownElRef.current;
1134-
if (!dropdownContainer.contains(targetElement)) {
1129+
if (
1130+
!(targetElement instanceof HTMLElement) ||
1131+
!dropdownContainer.contains(targetElement)
1132+
) {
11351133
return;
11361134
}
11371135

src/scripts/Picklist.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,11 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
312312
`${optionIdPrefix}-${nextFocusedValue}`
313313
);
314314

315-
if (!(targetElement instanceof HTMLElement)) {
316-
return;
317-
}
318-
319315
const dropdownContainer = dropdownElRef.current;
320-
if (!dropdownContainer.contains(targetElement)) {
316+
if (
317+
!(targetElement instanceof HTMLElement) ||
318+
!dropdownContainer.contains(targetElement)
319+
) {
321320
return;
322321
}
323322

0 commit comments

Comments
 (0)