Skip to content

Commit

Permalink
[MA-12]: Update aria attributes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SaurabhSharma-884 committed Dec 17, 2024
1 parent a889b4e commit 8ac7d8e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ exports[`components/AutosizeTextarea should match snapshot, init 1`] = `
}
/>
<textarea
aria-label=""
aria-labelledby="autosize_textarea_label"
data-testid="autosize_textarea"
dir="auto"
height={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ describe('components/avanced_text_editor/advanced_text_editor', () => {
}),
);

expect(screen.getByLabelText('write to test channel')).toHaveValue('original draft');
expect(screen.getByPlaceholderText('Write to Test Channel')).toHaveValue('original draft');

rerender(
<AdvancedTextEditor
{...baseProps}
channelId={otherChannelId}
/>,
);
expect(screen.getByLabelText('write to other channel')).toHaveValue('a different draft');
expect(screen.getByPlaceholderText('Write to Other Channel')).toHaveValue('a different draft');
});

it('should save a new draft when changing channels', () => {
Expand All @@ -246,7 +246,7 @@ describe('components/avanced_text_editor/advanced_text_editor', () => {
initialState,
);

userEvent.type(screen.getByLabelText('write to test channel'), 'some text');
userEvent.type(screen.getByPlaceholderText('Write to Test Channel'), 'some text');

expect(mockedUpdateDraft).not.toHaveBeenCalled();

Expand Down Expand Up @@ -312,7 +312,7 @@ describe('components/avanced_text_editor/advanced_text_editor', () => {
}),
);

userEvent.type(screen.getByLabelText('write to test channel'), ' plus some new text');
userEvent.type(screen.getByPlaceholderText('Write to Test Channel'), ' plus some new text');

expect(mockedUpdateDraft).not.toHaveBeenCalled();

Expand Down Expand Up @@ -348,7 +348,7 @@ describe('components/avanced_text_editor/advanced_text_editor', () => {
}),
);

userEvent.clear(screen.getByLabelText('write to test channel'));
userEvent.clear(screen.getByPlaceholderText('Write to Test Channel'));

expect(mockedRemoveDraft).not.toHaveBeenCalled();
expect(mockedUpdateDraft).not.toHaveBeenCalled();
Expand Down
4 changes: 1 addition & 3 deletions webapp/channels/src/components/autosize_textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ const AutosizeTextarea = React.forwardRef<HTMLTextAreaElement, Props>(({
}

let textareaPlaceholder = null;
const placeholderAriaLabel = placeholder ? placeholder.toLowerCase() : '';
if (!value && !defaultValue) {
textareaPlaceholder = (
<div
Expand Down Expand Up @@ -166,9 +165,8 @@ const AutosizeTextarea = React.forwardRef<HTMLTextAreaElement, Props>(({
id={id}
{...heightProps}
{...otherProps}
placeholder={placeholder}
role='textbox'
aria-label={placeholderAriaLabel}
aria-labelledby={`${id}_label`}
dir='auto'
disabled={disabled}
onChange={onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,8 @@ exports[`components/EditChannelHeaderModal edit direct message channel 1`] = `
>
<div>
<label
className="textarea-label"
htmlFor="edit_textbox"
id="edit_textbox_label"
style={
Object {
"fontWeight": "400",
"marginBottom": "10px",
}
}
>
<MemoizedFormattedMessage
defaultMessage="Edit the text appearing next to the channel name in the header."
Expand Down Expand Up @@ -193,14 +187,8 @@ exports[`components/EditChannelHeaderModal error with intl message 1`] = `
>
<div>
<label
className="textarea-label"
htmlFor="edit_textbox"
id="edit_textbox_label"
style={
Object {
"fontWeight": "400",
"marginBottom": "10px",
}
}
>
<MemoizedFormattedMessage
defaultMessage="Edit the text appearing next to the channel name in the header."
Expand Down Expand Up @@ -350,14 +338,8 @@ exports[`components/EditChannelHeaderModal error without intl message 1`] = `
>
<div>
<label
className="textarea-label"
htmlFor="edit_textbox"
id="edit_textbox_label"
style={
Object {
"fontWeight": "400",
"marginBottom": "10px",
}
}
>
<MemoizedFormattedMessage
defaultMessage="Edit the text appearing next to the channel name in the header."
Expand Down Expand Up @@ -499,14 +481,8 @@ exports[`components/EditChannelHeaderModal should match snapshot, init 1`] = `
>
<div>
<label
className="textarea-label"
htmlFor="edit_textbox"
id="edit_textbox_label"
style={
Object {
"fontWeight": "400",
"marginBottom": "10px",
}
}
>
<MemoizedFormattedMessage
defaultMessage="Edit the text appearing next to the channel name in the header."
Expand Down Expand Up @@ -638,14 +614,8 @@ exports[`components/EditChannelHeaderModal submitted 1`] = `
>
<div>
<label
className="textarea-label"
htmlFor="edit_textbox"
id="edit_textbox_label"
style={
Object {
"fontWeight": "400",
"marginBottom": "10px",
}
}
>
<MemoizedFormattedMessage
defaultMessage="Edit the text appearing next to the channel name in the header."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ export class EditChannelHeaderModal extends React.PureComponent<Props, State> {
<div>
<label
htmlFor='edit_textbox'
id='edit_textbox_label'
style={{
fontWeight: '400',
marginBottom: '10px',
}}
className='textarea-label'
>
<FormattedMessage
id='edit_channel_header_modal.description'
Expand Down
5 changes: 5 additions & 0 deletions webapp/channels/src/sass/components/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
.edit-modal-body {
overflow: visible;

.textarea-label {
margin-bottom: 10px;
font-weight: 400;
}

.custom-textarea {
height: auto;
min-height: 8em;
Expand Down

0 comments on commit 8ac7d8e

Please sign in to comment.