Skip to content

Commit

Permalink
fix(textarea): fixed the color of disabled textarea values
Browse files Browse the repository at this point in the history
  • Loading branch information
richbachman committed May 3, 2021
1 parent ebd61de commit 87fc917
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/itchy-countries-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@twilio-paste/input': patch
'@twilio-paste/textarea': patch
'@twilio-paste/core': patch
---

Fix disabled value color in Safari.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import * as React from 'react';
import {render} from 'react-dom';
import {matchers} from 'jest-emotion';
import {render as testRender, fireEvent} from '@testing-library/react';
import {Label} from '@twilio-paste/label';
import {HelpText} from '@twilio-paste/help-text';
// @ts-ignore typescript doesn't like js imports
import axe from '../../../../../.jest/axe-helper';
import {TextArea} from '../src';

expect.extend(matchers);

const NOOP = (): void => {};

const initialProps = {
Expand Down Expand Up @@ -35,6 +38,7 @@ describe('TextArea render', () => {
it('should render as disabled', () => {
const {getByRole} = testRender(<TextArea {...initialProps} disabled />);
expect(getByRole('textbox').getAttribute('disabled')).toEqual('');
expect(getByRole('textbox')).toHaveStyleRule('-webkit-text-fill-color', 'colorTextWeaker', {target: ':disabled'});
});

it('should render an id', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/paste-core/components/textarea/src/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const TextAreaElement = styled(TextareaAutosize)<TextAreaProps>((props) =>
'&:disabled': {
color: props.variant === 'inverse' ? 'colorTextInverseWeaker' : 'colorTextWeaker',
cursor: 'not-allowed',
// Fixes value color in Safari
'-webkit-text-fill-color': props.variant === 'inverse' ? 'colorTextInverseWeaker' : 'colorTextWeaker',
'-webkit-opacity': '1',
},
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export const TextareaDisabled = (): React.ReactNode => {
<TextArea
id={uid}
placeholder="Placeholder"
value="Disabled text content..."
disabled
onChange={action('handleFocus')}
onFocus={action('handleFocus')}
Expand All @@ -221,6 +222,7 @@ export const TextareaDisabledInverse = (): React.ReactNode => {
<TextArea
id={uid}
placeholder="Placeholder"
value="Disabled text content..."
disabled
onChange={action('handleFocus')}
onFocus={action('handleFocus')}
Expand Down

0 comments on commit 87fc917

Please sign in to comment.