@@ -122,6 +122,32 @@ export function AgentCreationPreview({
122122 isAvatarMenuOpen && activeTab === "emoji" ,
123123 ) ;
124124
125+ // Emoji Mart mounts its search input inside a shadow root. Wait for it
126+ // before focusing so the surrounding Radix popover cannot win the race.
127+ React . useEffect ( ( ) => {
128+ if ( ! isAvatarMenuOpen || activeTab !== "emoji" ) {
129+ return ;
130+ }
131+
132+ let animationFrame = 0 ;
133+ const focusSearchInput = ( ) => {
134+ const searchInput =
135+ emojiPickerContainerRef . current
136+ ?. querySelector ( "em-emoji-picker" )
137+ ?. shadowRoot ?. querySelector < HTMLInputElement > (
138+ 'input[type="search"]' ,
139+ ) ?? null ;
140+ if ( ! searchInput ) {
141+ animationFrame = window . requestAnimationFrame ( focusSearchInput ) ;
142+ return ;
143+ }
144+ searchInput . focus ( ) ;
145+ } ;
146+
147+ animationFrame = window . requestAnimationFrame ( focusSearchInput ) ;
148+ return ( ) => window . cancelAnimationFrame ( animationFrame ) ;
149+ } , [ activeTab , isAvatarMenuOpen ] ) ;
150+
125151 const customColorDraft = React . useMemo (
126152 ( ) => hsvToHex ( customHue , customSaturation , customValue ) ,
127153 [ customHue , customSaturation , customValue ] ,
@@ -526,6 +552,7 @@ export function AgentCreationPreview({
526552 style = { emojiMartThemeVars }
527553 >
528554 < Picker
555+ autoFocus
529556 categories = { EMOJI_MART_CATEGORIES }
530557 data = { emojiData }
531558 dynamicWidth
@@ -553,7 +580,7 @@ export function AgentCreationPreview({
553580 applyEmojiAvatar ( emoji . native , nextColor ) ;
554581 } }
555582 previewPosition = "none"
556- searchPosition = "none "
583+ searchPosition = "sticky "
557584 set = "native"
558585 skinTonePosition = "none"
559586 theme = "auto"
0 commit comments