@@ -2,6 +2,7 @@ import classNames from 'classnames';
22import KeyCode from 'rc-util/lib/KeyCode' ;
33import * as React from 'react' ;
44import type { NoticeConfig } from './interface' ;
5+ import pickAttrs from 'rc-util/lib/pickAttrs' ;
56
67export interface NoticeProps extends Omit < NoticeConfig , 'onClose' > {
78 prefixCls : string ;
@@ -60,6 +61,19 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
6061 // eslint-disable-next-line react-hooks/exhaustive-deps
6162 } , [ duration , mergedHovering , times ] ) ;
6263
64+ // ======================== Closable ========================
65+ const closableObj = React . useMemo ( ( ) => {
66+ if ( typeof closable === 'object' && closable !== null ) {
67+ return closable ;
68+ }
69+ if ( closable ) {
70+ return { closeIcon } ;
71+ }
72+ return { } ;
73+ } , [ closable , closeIcon ] ) ;
74+
75+ const ariaProps = pickAttrs ( closableObj , true ) ;
76+
6377 // ======================== Render ========================
6478 const noticePrefixCls = `${ prefixCls } -notice` ;
6579
@@ -90,13 +104,15 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
90104 tabIndex = { 0 }
91105 className = { `${ noticePrefixCls } -close` }
92106 onKeyDown = { onCloseKeyDown }
107+ aria-label = "Close"
108+ { ...ariaProps }
93109 onClick = { ( e ) => {
94110 e . preventDefault ( ) ;
95111 e . stopPropagation ( ) ;
96112 onInternalClose ( ) ;
97113 } }
98114 >
99- { closeIcon }
115+ { closableObj . closeIcon }
100116 </ a >
101117 ) }
102118 </ div >
0 commit comments