File tree Expand file tree Collapse file tree
components/input/src/input Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,6 +219,8 @@ export class Input extends Component {
219219 const exceedsMaximum = showCounter && valueLength > maxChars
220220 const counterId = showCounter && name ? `${ name } -counter` : undefined
221221
222+ const showClearButton = clearable && value ?. length > 0
223+
222224 const endItemsEnd = statusIcon ? '38px' : '8px'
223225
224226 return (
@@ -265,17 +267,17 @@ export class Input extends Component {
265267 'read-only' : readOnly ,
266268 } ) }
267269 />
268- { showCounter ? (
270+ { showCounter && (
269271 < span className = "input-end-items" >
270- { clearable && value ?. length ? (
272+ { showClearButton && (
271273 < button
272274 type = "button"
273275 onClick = { this . handleClear }
274276 className = "clear-button"
275277 >
276278 < IconCross16 color = { colors . white } />
277279 </ button >
278- ) : null }
280+ ) }
279281 < span
280282 id = { counterId }
281283 className = { cx ( 'character-counter' , {
@@ -286,15 +288,16 @@ export class Input extends Component {
286288 { valueLength } /{ maxChars }
287289 </ span >
288290 </ span >
289- ) : clearable && value ?. length ? (
291+ ) }
292+ { ! showCounter && showClearButton && (
290293 < button
291294 type = "button"
292295 onClick = { this . handleClear }
293296 className = "clear-button"
294297 >
295298 < IconCross16 color = { colors . white } />
296299 </ button >
297- ) : null }
300+ ) }
298301 < StatusIcon
299302 error = { error }
300303 valid = { valid }
You can’t perform that action at this time.
0 commit comments