mirror of
https://github.com/suitenumerique/docs
synced 2026-04-21 13:37:20 +00:00
♿️(frontend) restore focus on docIcon after picker
Use focus store to return focus after emoji picker close.
This commit is contained in:
parent
4c0c1f423e
commit
09fb9671e4
2 changed files with 8 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to
|
|||
### Changed
|
||||
|
||||
- 📝(docs) improve README and add documentation hub #1870
|
||||
- ♿️(frontend) restore focus to triggers after closing menus and modals #1863
|
||||
|
||||
## [v4.6.0] - 2026-03-03
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
TextType,
|
||||
emojidata,
|
||||
} from '@/components';
|
||||
import { useFocusStore } from '@/stores';
|
||||
|
||||
import { useDocTitleUpdate } from '../hooks/useDocTitleUpdate';
|
||||
|
||||
|
|
@ -41,6 +42,7 @@ export const DocIcon = ({
|
|||
}: DocIconProps) => {
|
||||
const { updateDocEmoji } = useDocTitleUpdate();
|
||||
const { t } = useTranslation();
|
||||
const { addLastFocus, restoreFocus } = useFocusStore();
|
||||
|
||||
const iconRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
|
@ -90,12 +92,16 @@ export const DocIcon = ({
|
|||
});
|
||||
}
|
||||
|
||||
if (!openEmojiPicker) {
|
||||
addLastFocus(iconRef.current);
|
||||
}
|
||||
setOpenEmojiPicker(!openEmojiPicker);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEmojiSelect = ({ native }: { native: string }) => {
|
||||
setOpenEmojiPicker(false);
|
||||
restoreFocus();
|
||||
|
||||
// Update document emoji if docId is provided
|
||||
if (docId && title !== undefined) {
|
||||
|
|
@ -108,6 +114,7 @@ export const DocIcon = ({
|
|||
|
||||
const handleClickOutside = () => {
|
||||
setOpenEmojiPicker(false);
|
||||
restoreFocus();
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue