Skip to content

feat: Support icon placeholders in Attachment, onToggle, and other PromptField updates - #10416

Open
LFDanLu wants to merge 12 commits into
mainfrom
coworker_followups_pt2
Open

feat: Support icon placeholders in Attachment, onToggle, and other PromptField updates#10416
LFDanLu wants to merge 12 commits into
mainfrom
coworker_followups_pt2

Conversation

@LFDanLu

@LFDanLu LFDanLu commented Aug 3, 2026

Copy link
Copy Markdown
Member

more followups for coworker

includes support for icon placeholders in Attachments, onToggle on VoiceInputButton for tracking, exposing PromptField focusable ref so "suggested prompt" buttons can move focus into the PromptField on value injection, and menuWidth to hack around weird popover resizing behavior when opened at edge of screen.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Test icon placeholders in Attachment stories
Test the suggested prompt buttons in the "Everything" story for PromptField and make sure focus moves into the field. Also test the menuWidth applies to the field's autocomplete menu and that onToggle triggers on voice input button toggle.

🧢 Your Project:

RSP

};
}

export function createFocusableRef<T extends HTMLElement = HTMLElement, D extends HTMLElement = T>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we import from the private path? why do we even have this file? there should be a comment in here explaining why we've copied it, haha

@LFDanLu LFDanLu Aug 3, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are just mimicking how S2 copies this over from the v3 package to isolate/guard against any possible divergences? Came in from #10095

@LFDanLu LFDanLu changed the title feat: (WIP) Support icon placeholders in Attachment, onToggle, and other PromptField updates feat: Support icon placeholders in Attachment, onToggle, and other PromptField updates Aug 4, 2026
@LFDanLu
LFDanLu marked this pull request as ready for review August 4, 2026 18:17
@rspbot

rspbot commented Aug 4, 2026

Copy link
Copy Markdown

@rspbot

rspbot commented Aug 4, 2026

Copy link
Copy Markdown
## API Changes

@react-spectrum/ai

/@react-spectrum/ai:PromptTokenField

 PromptTokenField {
   children?: (TokenSegment) => React.ReactElement
   completionTrigger?: RegExp
+  menuWidth?: number
   onKeyDown?: (React.KeyboardEvent<HTMLDivElement>) => void
   pixelLoader?: Array<Cell> | Array<Array<Cell>>
   placeholder?: string
   renderCompletions?: (string) => Array<React.ReactNode> | null | Promise<Array<React.ReactNode> | null>

/@react-spectrum/ai:PromptFieldVoiceButton

 PromptFieldVoiceButton {
   isDisabled?: boolean
   lang?: string
   onError?: (VoiceInputErrorCode) => void
+  onToggle?: (boolean) => void
 }

/@react-spectrum/ai:PromptTokenFieldProps

 PromptTokenFieldProps {
   children?: (TokenSegment) => React.ReactElement
   completionTrigger?: RegExp
+  menuWidth?: number
   onKeyDown?: (React.KeyboardEvent<HTMLDivElement>) => void
   pixelLoader?: Array<Cell> | Array<Array<Cell>>
   placeholder?: string
   renderCompletions?: (string) => Array<React.ReactNode> | null | Promise<Array<React.ReactNode> | null>

/@react-spectrum/ai:PromptTokenFieldPopoverProps

 PromptTokenFieldPopoverProps {
   UNSAFE_className?: UnsafeClassName
   UNSAFE_style?: CSSProperties
   aria-describedby?: string
   aria-details?: string
   aria-label?: string
   aria-labelledby?: string
   arrowRef?: RefObject<Element | null>
   boundaryElement?: Element = document.body
   children?: ChildrenOrFunction<PopoverRenderProps>
   containerPadding?: number = 12
   crossOffset?: number = 0
   defaultOpen?: boolean
   filterAnchor?: Position | null
   getTargetRect?: (Element) => DOMRect | null | undefined = target.getBoundingClientRect()
   hideArrow?: boolean = false
   isEntering?: boolean
   isExiting?: boolean
   isFocused?: boolean
   isNonModal?: boolean
   isOpen?: boolean
   items?: Array<React.ReactNode> | null | Promise<Array<React.ReactNode> | null>
   maxHeight?: number
+  menuWidth?: number
   offset?: number = 8
   onBlurWithin?: (FocusEvent) => void
   onFocusWithin?: (FocusEvent) => void
   onFocusWithinChange?: (boolean) => void
   placement?: Placement = 'bottom'
   scrollRef?: RefObject<Element | null> = overlayRef
   shouldFlip?: boolean = true
   size?: 'S' | 'M' | 'L'
   slot?: string | null
   styles?: StyleString
   trigger?: string
   triggerRef?: RefObject<Element | null>
 }

/@react-spectrum/ai:PromptFieldVoiceButtonProps

 PromptFieldVoiceButtonProps {
   isDisabled?: boolean
   lang?: string
   onError?: (VoiceInputErrorCode) => void
+  onToggle?: (boolean) => void
 }

@rspbot

rspbot commented Aug 4, 2026

Copy link
Copy Markdown

Agent Skills Changes

Modified (2)
Install

React Spectrum S2:

npx skills add https://d1pzu54gtk2aed.cloudfront.net/pr/a2664a8899d9fa8dfc7477cd8f8600277d5317ac/

React Aria:

npx skills add https://d5iwopk28bdhl.cloudfront.net/pr/a2664a8899d9fa8dfc7477cd8f8600277d5317ac/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants