@@ -432,3 +432,117 @@ test("a system message accepts a custom-emoji reaction", async ({ page }) => {
432432 . locator ( `img[alt=':${ REACTION_SHORTCODE } :']` ) ;
433433 await expect ( reactionImg ) . toBeVisible ( ) ;
434434} ) ;
435+
436+ test ( "emoji picker search input has spellcheck, autocorrect, and autocapitalize disabled" , async ( {
437+ page,
438+ } ) => {
439+ await openGeneral ( page ) ;
440+
441+ // Open the reaction picker on the seeded reactable message.
442+ const row = reactionTargetRow ( page ) ;
443+ await expect ( row ) . toBeVisible ( ) ;
444+ await row . hover ( ) ;
445+ await row . getByLabel ( "Open reactions" ) . click ( ) ;
446+
447+ // Wait for the picker to be visible, then read the shadow-root input attributes.
448+ const picker = page . locator ( "em-emoji-picker" ) ;
449+ await expect ( picker . locator ( "input[type='search']" ) ) . toBeVisible ( ) ;
450+
451+ const attrs = await picker . evaluate ( ( el : Element ) => {
452+ const input = (
453+ el as HTMLElement & { shadowRoot : ShadowRoot }
454+ ) . shadowRoot ?. querySelector < HTMLInputElement > ( 'input[type="search"]' ) ;
455+ if ( ! input ) throw new Error ( "search input not found in shadow root" ) ;
456+ return {
457+ spellcheck : input . spellcheck ,
458+ autocorrect : input . getAttribute ( "autocorrect" ) ,
459+ autocapitalize : input . getAttribute ( "autocapitalize" ) ,
460+ } ;
461+ } ) ;
462+
463+ expect ( attrs . spellcheck ) . toBe ( false ) ;
464+ expect ( attrs . autocorrect ) . toBe ( "off" ) ;
465+ expect ( attrs . autocapitalize ) . toBe ( "off" ) ;
466+ } ) ;
467+
468+ // Regression guard for PR #1438: after the spellcheck fix, the shadow-DOM
469+ // traversal must also own autofocus so Radix's focus-scope can't steal it.
470+ // Will reported that opening the picker required a manual click before typing.
471+ test ( "emoji picker search input is focused immediately on open (no manual click needed)" , async ( {
472+ page,
473+ } ) => {
474+ await openGeneral ( page ) ;
475+
476+ // Open the reaction picker — it passes autoFocus, so the input must receive
477+ // focus via our shadow traversal before the user interacts.
478+ const row = reactionTargetRow ( page ) ;
479+ await expect ( row ) . toBeVisible ( ) ;
480+ await row . hover ( ) ;
481+ await row . getByLabel ( "Open reactions" ) . click ( ) ;
482+
483+ const picker = page . locator ( "em-emoji-picker" ) ;
484+ await expect ( picker . locator ( "input[type='search']" ) ) . toBeVisible ( ) ;
485+
486+ // The search input must be the active element inside the shadow root.
487+ // If Radix's focus-scope wins instead, shadowRoot.activeElement is the
488+ // popover host (or null), not the input — this assertion catches that.
489+ const isFocused = await picker . evaluate ( ( el : Element ) => {
490+ const host = el as HTMLElement & { shadowRoot : ShadowRoot } ;
491+ const input = host . shadowRoot ?. querySelector < HTMLInputElement > (
492+ 'input[type="search"]' ,
493+ ) ;
494+ if ( ! input ) return false ;
495+ return host . shadowRoot ?. activeElement === input ;
496+ } ) ;
497+ expect ( isFocused ) . toBe ( true ) ;
498+ } ) ;
499+
500+ test ( "composer emoji picker search input is focused immediately on open" , async ( {
501+ page,
502+ } ) => {
503+ await openGeneral ( page ) ;
504+
505+ // Open the composer emoji picker via the toolbar button.
506+ await page . getByTestId ( "composer-emoji-button" ) . click ( ) ;
507+
508+ const picker = page . locator ( "em-emoji-picker" ) ;
509+ await expect ( picker . locator ( "input[type='search']" ) ) . toBeVisible ( ) ;
510+
511+ // The search input must be the active element inside the shadow root so
512+ // the user can type immediately without a manual click.
513+ const isFocused = await picker . evaluate ( ( el : Element ) => {
514+ const host = el as HTMLElement & { shadowRoot : ShadowRoot } ;
515+ const input = host . shadowRoot ?. querySelector < HTMLInputElement > (
516+ 'input[type="search"]' ,
517+ ) ;
518+ if ( ! input ) return false ;
519+ return host . shadowRoot ?. activeElement === input ;
520+ } ) ;
521+ expect ( isFocused ) . toBe ( true ) ;
522+
523+ // Pick an emoji and verify focus returns to the composer message input,
524+ // not left stranded in the now-closed popover. The insertEmoji handler
525+ // calls editor.chain().focus() before setIsEmojiPickerOpen(false), so
526+ // the Tiptap editor owns focus before Radix's onCloseAutoFocus fires.
527+ await picker . getByRole ( "button" , { name : "😀" } ) . first ( ) . click ( ) ;
528+ await expect ( page . getByTestId ( "message-input" ) ) . toBeFocused ( ) ;
529+ } ) ;
530+
531+ test ( "composer emoji picker restores editor focus on Escape dismiss" , async ( {
532+ page,
533+ } ) => {
534+ await openGeneral ( page ) ;
535+
536+ // Open the composer emoji picker via the toolbar button.
537+ await page . getByTestId ( "composer-emoji-button" ) . click ( ) ;
538+
539+ const picker = page . locator ( "em-emoji-picker" ) ;
540+ await expect ( picker . locator ( "input[type='search']" ) ) . toBeVisible ( ) ;
541+
542+ // Dismiss via Escape without selecting an emoji. The onClose callback
543+ // in ComposerEmojiPicker must restore focus to the editor so the user
544+ // can keep typing without an extra click.
545+ await page . keyboard . press ( "Escape" ) ;
546+
547+ await expect ( page . getByTestId ( "message-input" ) ) . toBeFocused ( ) ;
548+ } ) ;
0 commit comments