[MM-61616]: Add tab roles inside Emoji Picker (#29902)

* MM-61616: Add tab roles inside Emoji Picker

* MM-61616: Update snapshot tests

* MM-61616: Update emoji_picker_category E2E

* MM-61616: Minor aria properties changes

* [MM-61616]: Removed tab roles from emoji picker and added aria-pressed attribute in button

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
ayush-chauhan233
2025-02-20 02:24:59 +05:30
коммит произвёл GitHub
родитель 4aa4f6f703
Коммит d76e0b9d3d
4 изменённых файлов: 50 добавлений и 50 удалений

Просмотреть файл

@@ -38,96 +38,96 @@ exports[`components/emoji_picker/EmojiPicker should match snapshot 1`] = `
class="emoji-picker__categories" class="emoji-picker__categories"
id="emojiPickerCategories" id="emojiPickerCategories"
> >
<a <button
aria-label="Smileys & Emotion" aria-label="Smileys & Emotion"
class="emoji-picker__category emoji-picker__category--selected" aria-pressed="true"
href="#" class="style--none emoji-picker__category emoji-picker__category--selected"
> >
<i <i
class="icon-emoticon-happy-outline" class="icon-emoticon-happy-outline"
/> />
</a> </button>
<a <button
aria-label="People & Body" aria-label="People & Body"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-account-outline" class="icon-account-outline"
/> />
</a> </button>
<a <button
aria-label="Animals & Nature" aria-label="Animals & Nature"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-leaf-outline" class="icon-leaf-outline"
/> />
</a> </button>
<a <button
aria-label="Food & Drink" aria-label="Food & Drink"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-food-apple" class="icon-food-apple"
/> />
</a> </button>
<a <button
aria-label="Travel & Places" aria-label="Travel & Places"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-airplane-variant" class="icon-airplane-variant"
/> />
</a> </button>
<a <button
aria-label="Activities" aria-label="Activities"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-basketball" class="icon-basketball"
/> />
</a> </button>
<a <button
aria-label="Objects" aria-label="Objects"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-lightbulb-outline" class="icon-lightbulb-outline"
/> />
</a> </button>
<a <button
aria-label="Symbols" aria-label="Symbols"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-heart-outline" class="icon-heart-outline"
/> />
</a> </button>
<a <button
aria-label="Flags" aria-label="Flags"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-flag-outline" class="icon-flag-outline"
/> />
</a> </button>
<a <button
aria-label="Custom" aria-label="Custom"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="icon-emoticon-custom-outline" class="icon-emoticon-custom-outline"
/> />
</a> </button>
</div> </div>
<div <div
class="emoji-picker__items" class="emoji-picker__items"

Просмотреть файл

@@ -2,14 +2,14 @@
exports[`EmojiPickerCategory should match snapshot 1`] = ` exports[`EmojiPickerCategory should match snapshot 1`] = `
<DocumentFragment> <DocumentFragment>
<a <button
aria-label="category name" aria-label="category name"
class="emoji-picker__category" aria-pressed="false"
href="#" class="style--none emoji-picker__category"
> >
<i <i
class="categoryClass" class="categoryClass"
/> />
</a> </button>
</DocumentFragment> </DocumentFragment>
`; `;

Просмотреть файл

@@ -43,14 +43,14 @@ describe('EmojiPickerCategory', () => {
renderWithContext(<EmojiPickerCategory {...props}/>); renderWithContext(<EmojiPickerCategory {...props}/>);
// TODO: Change when we actually disabled the element when enable is false // TODO: Change when we actually disabled the element when enable is false
expect(screen.getByRole('link')).toHaveClass('emoji-picker__category disable'); expect(screen.getByRole('button')).toHaveClass('emoji-picker__category disable');
}); });
test('should have tooltip on hover', async () => { test('should have tooltip on hover', async () => {
renderWithContext(<EmojiPickerCategory {...defaultProps}/>); renderWithContext(<EmojiPickerCategory {...defaultProps}/>);
await act(async () => { await act(async () => {
const emojiPickerCategory = screen.getByRole('link'); const emojiPickerCategory = screen.getByRole('button');
userEvent.hover(emojiPickerCategory); userEvent.hover(emojiPickerCategory);
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
}); });

Просмотреть файл

@@ -42,14 +42,14 @@ function EmojiPickerCategory({category, categoryRowIndex, selected, enable, onCl
<FormattedMessage {...category.label}/> <FormattedMessage {...category.label}/>
} }
> >
<a <button
className={className} aria-pressed={selected}
href='#' className={classNames('style--none', className)}
onClick={handleClick} onClick={handleClick}
aria-label={intl.formatMessage(category.label)} aria-label={intl.formatMessage(category.label)}
> >
<i className={category.iconClassName}/> <i className={category.iconClassName}/>
</a> </button>
</WithTooltip> </WithTooltip>
); );
} }