Skip to content

Commit

Permalink
fix: only focus active elements
Browse files Browse the repository at this point in the history
  • Loading branch information
acdibble committed Nov 6, 2023
1 parent d73468a commit ffac7a5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ export default class App extends PureComponent<Props, State> {

focusNext = (): void => {
this.setState(previousState => {
const firstFocusableId = previousState.focusables[0]?.id;
const firstFocusableId = previousState.focusables.find(
focusable => focusable.isActive
)?.id;
const nextFocusableId = this.findNextFocusable(previousState);

return {
Expand All @@ -261,8 +263,9 @@ export default class App extends PureComponent<Props, State> {

focusPrevious = (): void => {
this.setState(previousState => {
const lastFocusableId = previousState.focusables.at(-1)?.id;

const lastFocusableId = previousState.focusables.findLast(
(focusable) => focusable.isActive
)?.id;
const previousFocusableId = this.findPreviousFocusable(previousState);

return {
Expand Down

0 comments on commit ffac7a5

Please sign in to comment.