Skip to content

Commit 5b99a1d

Browse files
committed
Fix linting and tests
1 parent 7a7ddb9 commit 5b99a1d

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

packages/react/src/ActionList/List.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export const List = React.forwardRef<HTMLUListElement, ActionListProps>(
4343
disabled: !enableFocusZone,
4444
containerRef: listRef,
4545
bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
46-
focusOutBehavior: listRole === 'menu' || container === 'SelectPanel' || container === 'FilteredActionList' ? 'wrap' : undefined,
46+
focusOutBehavior:
47+
listRole === 'menu' || container === 'SelectPanel' || container === 'FilteredActionList' ? 'wrap' : undefined,
4748
})
4849

4950
return (

packages/react/src/FilteredActionList/FilteredActionListWithModernActionList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function FilteredActionList({
7676
)
7777

7878
const [enableAnnouncements, setEnableAnnouncements] = useState(false)
79-
const [selectedItems, setSelectedItems] = useState<(string | number | undefined)[]>([])
79+
const [selectedItems] = useState<(string | number | undefined)[]>([])
8080

8181
const scrollContainerRef = useRef<HTMLDivElement>(null)
8282
const inputRef = useProvidedRefOrCreate<HTMLInputElement>(providedInputRef)
@@ -140,9 +140,9 @@ export function FilteredActionList({
140140
const updateActiveIndicator = () => {
141141
// Clear any existing active indicators
142142
const activeItems = list.querySelectorAll(`.${classes.ActiveItem}`)
143-
activeItems.forEach(item => {
143+
for (const item of activeItems) {
144144
item.classList.remove(classes.ActiveItem)
145-
})
145+
}
146146

147147
if (inputRef.current && document.activeElement === inputRef.current) {
148148
// When input is focused, mark the first item as active
@@ -175,7 +175,7 @@ export function FilteredActionList({
175175
return () => {
176176
document.removeEventListener('focusin', handleFocusIn)
177177
}
178-
}, [items]) // Re-run when items change to ensure first item is properly marked
178+
}, [items, inputRef]) // Re-run when items change to ensure first item is properly marked
179179

180180
useEffect(() => {
181181
setEnableAnnouncements(announcementsEnabled)

packages/react/src/FilteredActionList/useAnnouncements.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const useAnnouncements = (
2121
listContainerRef: React.RefObject<HTMLUListElement>,
2222
inputRef: React.RefObject<HTMLInputElement>,
2323
enabled: boolean = true,
24-
loading: boolean = false,
2524
) => {
2625
const liveRegion = document.querySelector('live-region')
2726

packages/react/src/SelectPanel/SelectPanel.test.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ for (const useModernActionList of [false, true]) {
395395
)
396396
})
397397

398-
it('should support navigating through items with PageDown and PageUp', async () => {
398+
it('should support navigating through items with PageDown and PageUp (modern ActionList)', async () => {
399399
if (!useModernActionList) return // this feature is only enabled with feature flag on
400400

401401
const user = userEvent.setup()
@@ -694,10 +694,11 @@ for (const useModernActionList of [false, true]) {
694694
jest.runAllTimers()
695695
// we wait because announcement is intentionally updated after a timeout to not interrupt user input
696696
await waitFor(async () => {
697+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
697698
if (useModernActionList) {
698-
expect(getLiveRegion().getMessage('polite')?.trim()).toEqual('3 items.')
699+
expect(getLiveRegion().getMessage('polite')!.trim()).toEqual('3 items available, 0 selected.')
699700
} else {
700-
expect(getLiveRegion().getMessage('polite')?.trim()).toEqual(
701+
expect(getLiveRegion().getMessage('polite')!.trim()).toEqual(
701702
'List updated, Focused item: item one, not selected, 1 of 3',
702703
)
703704
}
@@ -752,7 +753,7 @@ for (const useModernActionList of [false, true]) {
752753
await user.click(screen.getByText('Select items'))
753754
expect(screen.getByLabelText('Filter items')).toHaveFocus()
754755

755-
expect(getLiveRegion().getMessage('polite')?.trim()).toContain('This is a notice')
756+
expect(getLiveRegion().getMessage('polite')!.trim()).toContain('This is a notice')
756757
})
757758

758759
it('should announce filtered results', async () => {
@@ -768,10 +769,11 @@ for (const useModernActionList of [false, true]) {
768769
jest.runAllTimers()
769770
await waitFor(
770771
async () => {
772+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
771773
if (useModernActionList) {
772-
expect(getLiveRegion().getMessage('polite')?.trim()).toEqual('3 items.')
774+
expect(getLiveRegion().getMessage('polite')!.trim()).toEqual('3 items available, 0 selected.')
773775
} else {
774-
expect(getLiveRegion().getMessage('polite')?.trim()).toEqual(
776+
expect(getLiveRegion().getMessage('polite')!.trim()).toEqual(
775777
'List updated, Focused item: item one, not selected, 1 of 3',
776778
)
777779
}
@@ -785,8 +787,9 @@ for (const useModernActionList of [false, true]) {
785787
jest.runAllTimers()
786788
await waitFor(
787789
async () => {
790+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
788791
if (useModernActionList) {
789-
expect(getLiveRegion().getMessage('polite')).toBe('2 items.')
792+
expect(getLiveRegion().getMessage('polite')).toBe('2 items available, 0 selected.')
790793
} else {
791794
expect(getLiveRegion().getMessage('polite')).toBe(
792795
'List updated, Focused item: item one, not selected, 1 of 2',
@@ -801,10 +804,11 @@ for (const useModernActionList of [false, true]) {
801804

802805
jest.runAllTimers()
803806
await waitFor(async () => {
807+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
804808
if (useModernActionList) {
805-
expect(getLiveRegion().getMessage('polite')?.trim()).toBe('1 items.')
809+
expect(getLiveRegion().getMessage('polite')!.trim()).toBe('1 item available, 0 selected.')
806810
} else {
807-
expect(getLiveRegion().getMessage('polite')?.trim()).toBe(
811+
expect(getLiveRegion().getMessage('polite')!.trim()).toBe(
808812
'List updated, Focused item: item one, not selected, 1 of 1',
809813
)
810814
}

0 commit comments

Comments
 (0)