Skip to content

feat: Add renderCustomTrigger prop to Select#4589

Draft
taheramr wants to merge 1 commit into
mainfrom
feat/add-rendercustomtrigger-prop-select
Draft

feat: Add renderCustomTrigger prop to Select#4589
taheramr wants to merge 1 commit into
mainfrom
feat/add-rendercustomtrigger-prop-select

Conversation

@taheramr

@taheramr taheramr commented Jun 8, 2026

Copy link
Copy Markdown
Member

Adds a public renderCustomTrigger prop on Select that lets consumers fully replace the default trigger element while Select retains ownership of the dropdown lifecycle, focus return, ARIA wiring, and form-field integration.

The SelectProps.CustomTriggerProps props bag exposes:

  • triggerRef — attach to the focusable element so Select can return focus on close
  • isOpen — current dropdown state
  • onClick — toggles the dropdown open/closed
  • ariaProps — { id, 'aria-expanded', 'aria-labelledby', 'aria-describedby', 'aria-required' } to spread on the focusable element

The consumer is responsible for rendering aria-haspopup="listbox" on the focusable element themselves (fixed value, not in the bag).

When renderCustomTrigger is provided, the placeholder prop is not consumed by Select — the consumer renders their own empty state.

Test utilities:

  • New findCustomTrigger() returns the wrapper around the consumer's custom trigger; null for default Select.
  • Existing findTrigger() is unchanged for default Select; returns null when renderCustomTrigger is provided.

Backward compatible: default Select behavior is unchanged when the new prop is not provided.

Refs: AWSUI-61998

Description

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Adds a public `renderCustomTrigger` prop on Select that lets consumers fully replace the default trigger element while Select retains ownership of the dropdown lifecycle, focus return, ARIA wiring, and form-field integration.

The `SelectProps.CustomTriggerProps` props bag exposes:
- `triggerRef` — attach to the focusable element so Select can return focus on close
- `isOpen` — current dropdown state
- `onClick` — toggles the dropdown open/closed
- `ariaProps` — { id, 'aria-expanded', 'aria-labelledby', 'aria-describedby', 'aria-required' } to spread on the focusable element

The consumer is responsible for rendering `aria-haspopup="listbox"` on the focusable element themselves (fixed value, not in the bag).

When `renderCustomTrigger` is provided, the `placeholder` prop is not consumed by Select — the consumer renders their own empty state.

Test utilities:
- New `findCustomTrigger()` returns the wrapper around the consumer's custom trigger; null for default Select.
- Existing `findTrigger()` is unchanged for default Select; returns null when `renderCustomTrigger` is provided.

Backward compatible: default Select behavior is unchanged when the new prop is not provided.

Refs: AWSUI-61998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant