-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(flags): search button leads to focus in drawer (#77839)
Add a search icon button to the feature flag section, which opens the fly-out drawer with the search focused. This is the same behavior as the breadcrumbs section. https://github.com/user-attachments/assets/553cfd39-f4b3-480b-aa0d-ce961e2d6361
- Loading branch information
1 parent
460232f
commit d160151
Showing
6 changed files
with
74 additions
and
49 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
File renamed without changes.
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,21 @@ | ||
import {useCallback, useState} from 'react'; | ||
|
||
import type {BreadcrumbControlOptions} from 'sentry/components/events/breadcrumbs/breadcrumbsDrawer'; | ||
import type {FlagControlOptions} from 'sentry/components/events/featureFlags/featureFlagDrawer'; | ||
|
||
type FocusControlOption = BreadcrumbControlOptions | FlagControlOptions; | ||
|
||
export default function useFocusControl(initialFocusControl?: FocusControlOption) { | ||
const [focusControl, setFocusControl] = useState(initialFocusControl); | ||
// If the focused control element is blurred, unset the state to remove styles | ||
// This will allow us to simulate :focus-visible on the button elements. | ||
const getFocusProps = useCallback( | ||
(option: FocusControlOption) => { | ||
return option === focusControl | ||
? {autoFocus: true, onBlur: () => setFocusControl(undefined)} | ||
: {}; | ||
}, | ||
[focusControl] | ||
); | ||
return {getFocusProps}; | ||
} |
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