diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index cb2ac94a..1c65c250 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -129,7 +129,11 @@ export interface BaseSelectPrivateProps { export type BaseSelectPropsWithoutPrivate = Omit; -export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes { +export interface BaseSelectProps + extends + BaseSelectPrivateProps, + React.AriaAttributes, + Pick, 'role'> { // Style className?: string; style?: React.CSSProperties; diff --git a/src/SelectInput/index.tsx b/src/SelectInput/index.tsx index 79980956..6a11895a 100644 --- a/src/SelectInput/index.tsx +++ b/src/SelectInput/index.tsx @@ -11,6 +11,7 @@ import { clsx } from 'clsx'; import type { ComponentsConfig } from '../hooks/useComponents'; import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode'; import { composeRef } from '@rc-component/util/lib/ref'; +import pickAttrs from '@rc-component/util/lib/pickAttrs'; export interface SelectInputRef { focus: (options?: FocusOptions) => void; @@ -207,6 +208,8 @@ export default React.forwardRef(function Selec // ===================== Render ===================== const domProps = omit(restProps, DEFAULT_OMIT_PROPS as any); + const ariaProps = pickAttrs(domProps, { aria: true }); + const ariaKeys = Object.keys(ariaProps) as (keyof typeof domProps)[]; // Create context value with wrapped callbacks const contextValue = { @@ -228,7 +231,7 @@ export default React.forwardRef(function Selec return (
void; - role?: React.AriaRole; } export const BaseSelectContext = React.createContext(null); diff --git a/tests/Accessibility.test.tsx b/tests/Accessibility.test.tsx index 37940561..364cc37d 100644 --- a/tests/Accessibility.test.tsx +++ b/tests/Accessibility.test.tsx @@ -213,6 +213,34 @@ describe('Select.Accessibility', () => { } }); }); + + it('should pass aria and role attributes to Input component', async () => { + const { container } = render( +