From f39e4055d5033c326f62bd5ec9c97ffef1911d84 Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Wed, 28 Aug 2024 10:55:22 -0500 Subject: [PATCH] Revert "Focus on first item in revealed dropdown" This reverts commit 4a870d10d1a5519fb384dce21fdefd277b9a9b48. --- src/app/components/Dropdown.tsx | 15 +++------------ src/app/reactUtils.ts | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/app/components/Dropdown.tsx b/src/app/components/Dropdown.tsx index 294e8dec02..3a146cade1 100644 --- a/src/app/components/Dropdown.tsx +++ b/src/app/components/Dropdown.tsx @@ -1,12 +1,12 @@ -import { HTMLElement, HTMLMenuElement } from '@openstax/types/lib.dom'; +import { HTMLElement } from '@openstax/types/lib.dom'; import flow from 'lodash/fp/flow'; import isUndefined from 'lodash/fp/isUndefined'; import omitBy from 'lodash/fp/omitBy'; import React, { ReactNode } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import styled, { css, keyframes } from 'styled-components/macro'; -import { useFocusLost, useTrapTabNavigation, focusableItemQuery } from '../reactUtils'; +import { useFocusLost, useTrapTabNavigation } from '../reactUtils'; import { useOnEsc } from '../reactUtils'; import theme, { defaultFocusOutline } from '../theme'; import { preventDefault } from '../utils'; @@ -167,19 +167,10 @@ const TabTransparentDropdown = styled(( `; function TrappingDropdownList(props: object) { - const ref = React.useRef(null); + const ref = React.useRef(null); useTrapTabNavigation(ref); - React.useEffect( - () => { - if (ref.current?.querySelector) { - ref.current?.querySelector(focusableItemQuery)?.focus(); - } - }, - [] - ); - return ( ); diff --git a/src/app/reactUtils.ts b/src/app/reactUtils.ts index 55ecd50054..c66c004960 100644 --- a/src/app/reactUtils.ts +++ b/src/app/reactUtils.ts @@ -22,7 +22,7 @@ function isHidden(el: HTMLElement) { return el.offsetWidth === 0 && el.offsetHeight === 0; } -export const focusableItemQuery = [ +const focusableItemQuery = [ 'button', 'input', 'select', 'textarea', '[href]', '[tabindex]:not([tabindex="-1"]', ].map((s) => s.includes('[') ? s : `${s}:not([disabled])`).join(',');