Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Clean up BaseOptionsSelector #37353

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
21bc3e6
Use useArrowKeyFocusManager hook instead of ArrowKeyFocusManager comp…
roryabraham Feb 27, 2024
5c81404
Remove unnecessary focusedOption state variable
roryabraham Feb 27, 2024
af46a8a
Remove unnecessary useMemo, initialize state with function
roryabraham Feb 27, 2024
2748829
Use memo instead of state for allOptions
roryabraham Feb 27, 2024
5f1b6e3
use memo not state for paginated sections
roryabraham Feb 27, 2024
bbd1ce3
Get rid of unnecessary prevLocale and prevPaginationPage
roryabraham Feb 27, 2024
269b813
Use ref not state for shouldDisableRowSelection
roryabraham Feb 27, 2024
b747acf
Remove duplicate keyboard logic for enter and ctrl+enter
roryabraham Feb 27, 2024
ab6d66c
Improve typing of ActiveElementRoleProvider
roryabraham Feb 27, 2024
2d59cf3
Use useActiveElementRole hook directly
roryabraham Feb 27, 2024
bc3f695
use forwardRef directly
roryabraham Feb 27, 2024
e402317
Use usePrevious utility hook
roryabraham Feb 27, 2024
4c05b9e
Undo bad ref change
roryabraham Feb 27, 2024
91c956b
Help reduce diff a bit
roryabraham Feb 27, 2024
684be84
don't re-calculate focusedIndex unless options actually change
roryabraham Feb 27, 2024
6641c00
Use canFocusInputOnScreenFocus rather than getPlatform
roryabraham Feb 27, 2024
e3f13dd
Use useAutoFocusInput hook
roryabraham Feb 28, 2024
1ffd5c6
Remove unnecessary canFocusInputOnScreenFocus
roryabraham Feb 28, 2024
e6ee35f
Remove unused focusTimeout ref
roryabraham Feb 28, 2024
82d9773
Merge branch 'main' into Rory-BaseOptionsSelectorImprovements
roryabraham Feb 28, 2024
9990129
make sure enter keyboard shortcut is only active if the screen is foc…
roryabraham Feb 28, 2024
5288a65
Add back accidentally removed hook import
roryabraham Feb 28, 2024
43b8266
Remove adjustedSectionIndex
roryabraham Feb 28, 2024
c068e3d
Merge branch 'main' into Rory-BaseOptionsSelectorImprovements
roryabraham Feb 28, 2024
b031d1e
Use paginated sections to generate allOptions
roryabraham Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/ActiveElementRoleProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, {useEffect, useState} from 'react';
import type {ActiveElementRoleContextValue, ActiveElementRoleProps} from './types';
import type {ActiveElementRoleContextValue, ActiveElementRoleProps, AriaRole} from './types';

const ActiveElementRoleContext = React.createContext<ActiveElementRoleContextValue>({
role: null,
});

function ActiveElementRoleProvider({children}: ActiveElementRoleProps) {
const [activeRoleRef, setRole] = useState<string | null>(document?.activeElement?.role ?? null);
const [activeRoleRef, setRole] = useState<AriaRole | null>((document?.activeElement?.role as AriaRole) ?? null);

const handleFocusIn = () => {
setRole(document?.activeElement?.role ?? null);
setRole((document?.activeElement?.role as AriaRole) ?? null);
};

const handleFocusOut = () => {
Expand Down
9 changes: 7 additions & 2 deletions src/components/ActiveElementRoleProvider/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';

type AriaRole = ValueOf<typeof CONST.ROLE>;

type ActiveElementRoleContextValue = {
role: string | null;
role: AriaRole | null;
};

type ActiveElementRoleProps = {
children: React.ReactNode;
};

export type {ActiveElementRoleContextValue, ActiveElementRoleProps};
export type {AriaRole, ActiveElementRoleContextValue, ActiveElementRoleProps};
Loading
Loading