-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25955 from thiagobrez/thiagobrez/selection-list-r…
…egressions-2 [CP Staging] fix(selection-list): scroll to top, cmd enter, tab key (cherry picked from commit 09a07ae)
- Loading branch information
1 parent
01266ec
commit 2140c01
Showing
6 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {useEffect, useState} from 'react'; | ||
|
||
export default function useActiveElement() { | ||
const [active, setActive] = useState(document.activeElement); | ||
|
||
const handleFocusIn = () => { | ||
setActive(document.activeElement); | ||
}; | ||
|
||
const handleFocusOut = () => { | ||
setActive(null); | ||
}; | ||
|
||
useEffect(() => { | ||
document.addEventListener('focusin', handleFocusIn); | ||
document.addEventListener('focusout', handleFocusOut); | ||
|
||
return () => { | ||
document.removeEventListener('focusin', handleFocusIn); | ||
document.removeEventListener('focusout', handleFocusOut); | ||
}; | ||
}, []); | ||
|
||
return active; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function useActiveElement() { | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters