@@ -52,6 +52,7 @@ interface IInternalItem {
5252const Checkbox = ( {
5353 checked = false ,
5454 onChange = ( ) => { } ,
55+ title,
5556 ...otherProps
5657} : Item & IInternalItem ) => {
5758 const [ value , setValue ] = useState < boolean > ( checked ) ;
@@ -63,6 +64,7 @@ const Checkbox = ({
6364 < ClayCheckbox
6465 { ...otherProps }
6566 checked = { value }
67+ label = { title }
6668 onChange = { ( ) => {
6769 setValue ( ( val ) => ! val ) ;
6870 onChange ( ! value ) ;
@@ -76,7 +78,7 @@ const Checkbox = ({
7678type Context = {
7779 back ?: ( ) => void ;
7880 close : ( ) => void ;
79- onForward ?: ( label : string , id : string ) => void ;
81+ onForward ?: ( title : string , id : string ) => void ;
8082 messages ?: Record < string , string > ;
8183} ;
8284
@@ -89,17 +91,20 @@ const Item = ({
8991 label,
9092 onClick,
9193 spritemap,
94+ title,
9295 ...props
9396} : Omit < Item , 'onChange' > & IInternalItem ) => {
9497 const { back, close, messages, onForward} = useContext ( ClayDropDownContext ) ;
9598
99+ title = label || title ;
100+
96101 return (
97102 < DropDown . Item
98103 { ...props }
99104 onClick = { ( event ) => {
100- if ( onForward && child && label ) {
105+ if ( onForward && child && title ) {
101106 event . preventDefault ( ) ;
102- onForward ( label , child ) ;
107+ onForward ( title , child ) ;
103108
104109 return ;
105110 }
@@ -117,13 +122,13 @@ const Item = ({
117122 } }
118123 spritemap = { spritemap }
119124 >
120- { label }
125+ { title }
121126
122127 { child && (
123128 < span
124- aria-label = { `${ messages ! [ 'goTo' ] } ${ label } ` }
129+ aria-label = { `${ messages ! [ 'goTo' ] } ${ title } ` }
125130 className = "dropdown-item-indicator-end"
126- title = { `${ messages ! [ 'goTo' ] } ${ label } ` }
131+ title = { `${ messages ! [ 'goTo' ] } ${ title } ` }
127132 >
128133 < Icon spritemap = { spritemap } symbol = "angle-right" />
129134 </ span >
@@ -132,18 +137,20 @@ const Item = ({
132137 ) ;
133138} ;
134139
135- const Group = ( { items, label, spritemap} : Item & IInternalItem ) => {
140+ const Group = ( { items, label, spritemap, title} : Item & IInternalItem ) => {
141+ title = label || title ;
142+
136143 warning (
137144 typeof items !== 'undefined' ,
138- `ClayDropDownWithItems -> The '${ label } ' group contains no items to render.`
145+ `ClayDropDownWithItems -> The '${ title } ' group contains no items to render.`
139146 ) ;
140147
141148 if ( typeof items === 'undefined' ) {
142149 return null ;
143150 }
144151
145152 return (
146- < DropDownGroup header = { label } >
153+ < DropDownGroup header = { title } >
147154 { items && < Items items = { items } spritemap = { spritemap } /> }
148155 </ DropDownGroup >
149156 ) ;
@@ -180,6 +187,7 @@ const Contextual = ({
180187 items,
181188 label,
182189 spritemap,
190+ title,
183191 ...otherProps
184192} : Omit < Item , 'onChange' > & IInternalItem ) => {
185193 const [ visible , setVisible ] = useState ( false ) ;
@@ -215,6 +223,8 @@ const Contextual = ({
215223 [ ]
216224 ) ;
217225
226+ title = label || title ;
227+
218228 return (
219229 < DropDown . Item
220230 { ...otherProps }
@@ -263,7 +273,7 @@ const Contextual = ({
263273 spritemap = { spritemap }
264274 symbolRight = "angle-right"
265275 >
266- { label }
276+ { title }
267277
268278 { items && (
269279 < DropDown . Menu
@@ -331,7 +341,7 @@ interface IRadioContext {
331341
332342const RadioGroupContext = React . createContext ( { } as IRadioContext ) ;
333343
334- const Radio = ( { value = '' , ...otherProps } : Item & IInternalItem ) => {
344+ const Radio = ( { title , value = '' , ...otherProps } : Item & IInternalItem ) => {
335345 const { checked, name, onChange} = useContext ( RadioGroupContext ) ;
336346
337347 const { tabFocus} = useContext ( DropDownContext ) ;
@@ -342,6 +352,7 @@ const Radio = ({value = '', ...otherProps}: Item & IInternalItem) => {
342352 { ...otherProps }
343353 checked = { checked === value }
344354 inline
355+ label = { title }
345356 name = { name }
346357 onChange = { ( ) => onChange ( value as string ) }
347358 tabIndex = { ! tabFocus ? - 1 : undefined }
@@ -357,6 +368,7 @@ const RadioGroup = ({
357368 name,
358369 onChange = ( ) => { } ,
359370 spritemap,
371+ title,
360372 value : defaultValue = '' ,
361373} : Item & IInternalItem ) => {
362374 const [ value , setValue ] = useState ( defaultValue ) ;
@@ -370,13 +382,15 @@ const RadioGroup = ({
370382 } ,
371383 } ;
372384
385+ title = label || title ;
386+
373387 warning (
374388 items && items . filter ( ( item ) => item . type !== 'radio' ) . length === 0 ,
375389 'ClayDropDownWithItems -> Items of type `radiogroup` should be used `radio` if you need to use others, it is recommended to use type `group`.'
376390 ) ;
377391
378392 return (
379- < DropDownGroup header = { label } role = "radiogroup" >
393+ < DropDownGroup header = { title } role = "radiogroup" >
380394 { items && (
381395 < RadioGroupContext . Provider value = { params } >
382396 < Items items = { items } spritemap = { spritemap } />
0 commit comments