Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fix for issue #3867 - TextInput action hover state is incorrect #3894

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions src/TextInput/TextInput.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,24 @@ export const WithTrailingIcon = () => (
)

export const WithTrailingAction = () => {
const [value, setValue] = useState('')
const [value, setValue] = useState('Sample Text')

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setValue(event.target.value)
}

return (
<Box as="form">
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput
trailingAction={
<TextInput.Action
onClick={() => {
setValue('')
}}
icon={XCircleFillIcon}
aria-label="Clear input"
sx={{color: 'fg.subtle'}}
/>
<Box sx={{width: '30px', display: 'flex', alignItems: 'center'}}>
{/* TODO this behavior should ideally be baked into the component for actions like clear */}
{value.length > 0 && (
<TextInput.Action onClick={() => setValue('')} icon={XCircleFillIcon} aria-label="Clear input" />
)}
</Box>
}
value={value}
onChange={handleChange}
Expand All @@ -148,26 +147,41 @@ export const WithTrailingAction = () => {
}

export const WithTooltipDirection = () => {
const [value, setValue] = useState('')
const [value, setValue] = useState('Sample Text')

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setValue(event.target.value)
}

return (
<Box as="form">
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput
trailingAction={
<TextInput.Action
onClick={() => {
setValue('')
<Box
sx={{
width: '30px',
display: 'flex',
alignItems: 'center',
}}
icon={XCircleFillIcon}
aria-label="Clear input"
tooltipDirection="nw"
sx={{color: 'fg.subtle'}}
/>
>
{value.length > 0 && (
<TextInput.Action
onClick={() => {
setValue('')
}}
icon={XCircleFillIcon}
aria-label="Clear input"
tooltipDirection="nw"
sx={{
color: 'fg.muted',
backgroundColor: 'transparent',
'&:hover': {color: 'fg.subtle'},
}}
/>
)}
</Box>
}
value={value}
onChange={handleChange}
Expand Down
4 changes: 4 additions & 0 deletions src/internal/components/TextInputInnerAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const invisibleButtonStyleOverrides = {
paddingLeft: '4px',
position: 'relative',

backgroundColor: 'transparent',
color: 'fg.subtle',
'&:hover': {color: 'fg.muted'},

'&[data-component="IconButton"]': {
width: 'var(--inner-action-size)',
height: 'var(--inner-action-size)',
Expand Down
Loading