mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-28 02:20:47 +00:00
focus on mount
This commit is contained in:
parent
7382171650
commit
2661a53333
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import type { FC, MouseEventHandler } from 'react';
|
import type { FC, MouseEventHandler } from 'react';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
@ -32,12 +32,7 @@ export const MockEmojiPicker: FC<MockEmojiPickerProps> = ({ onSelect }) => {
|
||||||
[onSelect],
|
[onSelect],
|
||||||
);
|
);
|
||||||
|
|
||||||
const [showSettings, setShowSettings] = useState(false);
|
const { groups } = useLocaleMessages();
|
||||||
const handleSettingsClick: MouseEventHandler = useCallback((event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
setShowSettings((prev) => !prev);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const wrapperRef = useRef<HTMLDivElement>(null);
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
||||||
const handleGroupSelect = useCallback((key: string) => {
|
const handleGroupSelect = useCallback((key: string) => {
|
||||||
const wrapper = wrapperRef.current;
|
const wrapper = wrapperRef.current;
|
||||||
|
|
@ -57,7 +52,19 @@ export const MockEmojiPicker: FC<MockEmojiPickerProps> = ({ onSelect }) => {
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { groups } = useLocaleMessages();
|
const searchRef = useRef<HTMLInputElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const searchInput = searchRef.current;
|
||||||
|
if (!searchInput) return;
|
||||||
|
|
||||||
|
searchInput.focus();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const [showSettings, setShowSettings] = useState(false);
|
||||||
|
const handleSettingsClick: MouseEventHandler = useCallback((event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
setShowSettings((prev) => !prev);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomEmojiProvider emojis={mockCustomEmojis}>
|
<CustomEmojiProvider emojis={mockCustomEmojis}>
|
||||||
|
|
@ -67,6 +74,7 @@ export const MockEmojiPicker: FC<MockEmojiPickerProps> = ({ onSelect }) => {
|
||||||
type='search'
|
type='search'
|
||||||
placeholder='Search emojis'
|
placeholder='Search emojis'
|
||||||
className={classes.search}
|
className={classes.search}
|
||||||
|
ref={searchRef}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon='settings'
|
icon='settings'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user