[MM-61612]: Added dialog role to the emoji picker (#29690)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
effe018813
Коммит
7cd025d1fb
@@ -5,7 +5,8 @@ import classNames from 'classnames';
|
|||||||
import type {CSSProperties, RefObject} from 'react';
|
import type {CSSProperties, RefObject} from 'react';
|
||||||
import React, {PureComponent, createRef} from 'react';
|
import React, {PureComponent, createRef} from 'react';
|
||||||
import {Tab, Tabs} from 'react-bootstrap';
|
import {Tab, Tabs} from 'react-bootstrap';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import type {WrappedComponentProps} from 'react-intl';
|
||||||
|
import {injectIntl, FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import type {Emoji} from '@mattermost/types/emojis';
|
import type {Emoji} from '@mattermost/types/emojis';
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ import GifIcon from 'components/widgets/icons/giphy_icon';
|
|||||||
|
|
||||||
const GifPicker = makeAsyncComponent('GifPicker', React.lazy(() => import('components/gif_picker/gif_picker')));
|
const GifPicker = makeAsyncComponent('GifPicker', React.lazy(() => import('components/gif_picker/gif_picker')));
|
||||||
|
|
||||||
export interface Props {
|
export interface Props extends WrappedComponentProps {
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
rightOffset?: number;
|
rightOffset?: number;
|
||||||
topOffset?: number;
|
topOffset?: number;
|
||||||
@@ -33,9 +34,10 @@ export interface Props {
|
|||||||
type State = {
|
type State = {
|
||||||
emojiTabVisible: boolean;
|
emojiTabVisible: boolean;
|
||||||
filter: string;
|
filter: string;
|
||||||
|
activeKey: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
class EmojiPickerTabs extends PureComponent<Props, State> {
|
||||||
private rootPickerNodeRef: RefObject<HTMLDivElement>;
|
private rootPickerNodeRef: RefObject<HTMLDivElement>;
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@@ -50,6 +52,7 @@ export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
|||||||
this.state = {
|
this.state = {
|
||||||
emojiTabVisible: true,
|
emojiTabVisible: true,
|
||||||
filter: '',
|
filter: '',
|
||||||
|
activeKey: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.rootPickerNodeRef = createRef();
|
this.rootPickerNodeRef = createRef();
|
||||||
@@ -68,7 +71,9 @@ export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const {intl} = this.props;
|
||||||
let pickerStyle;
|
let pickerStyle;
|
||||||
|
|
||||||
if (this.props.style && !(this.props.style.left === 0 && this.props.style.top === 0)) {
|
if (this.props.style && !(this.props.style.left === 0 && this.props.style.top === 0)) {
|
||||||
if (this.props.placement === 'top' || this.props.placement === 'bottom') {
|
if (this.props.placement === 'top' || this.props.placement === 'bottom') {
|
||||||
// Only take the top/bottom position passed by React Bootstrap since we want to be right-aligned
|
// Only take the top/bottom position passed by React Bootstrap since we want to be right-aligned
|
||||||
@@ -101,6 +106,11 @@ export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
|||||||
className={classNames('a11y__popup', 'emoji-picker', {
|
className={classNames('a11y__popup', 'emoji-picker', {
|
||||||
bottom: this.props.placement === 'bottom',
|
bottom: this.props.placement === 'bottom',
|
||||||
})}
|
})}
|
||||||
|
role='dialog'
|
||||||
|
aria-label={this.state.activeKey === 1 ? intl.formatMessage({id: 'emoji_gif_picker.dialog.emojis', defaultMessage: 'Emoji Picker'}) : intl.formatMessage({id: 'emoji_gif_picker.dialog.gifs', defaultMessage: 'GIF Picker'})
|
||||||
|
}
|
||||||
|
|
||||||
|
aria-modal='true'
|
||||||
>
|
>
|
||||||
<Tabs
|
<Tabs
|
||||||
id='emoji-picker-tabs'
|
id='emoji-picker-tabs'
|
||||||
@@ -108,6 +118,8 @@ export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
|||||||
justified={true}
|
justified={true}
|
||||||
mountOnEnter={true}
|
mountOnEnter={true}
|
||||||
unmountOnExit={true}
|
unmountOnExit={true}
|
||||||
|
activeKey={this.state.activeKey}
|
||||||
|
onSelect={(activeKey) => this.setState({activeKey})}
|
||||||
>
|
>
|
||||||
<EmojiPickerHeader handleEmojiPickerClose={this.handleEmojiPickerClose}/>
|
<EmojiPickerHeader handleEmojiPickerClose={this.handleEmojiPickerClose}/>
|
||||||
<Tab
|
<Tab
|
||||||
@@ -170,6 +182,10 @@ export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
|||||||
className={classNames('a11y__popup', 'emoji-picker', 'emoji-picker--single', {
|
className={classNames('a11y__popup', 'emoji-picker', 'emoji-picker--single', {
|
||||||
bottom: this.props.placement === 'bottom',
|
bottom: this.props.placement === 'bottom',
|
||||||
})}
|
})}
|
||||||
|
role='dialog'
|
||||||
|
aria-label={
|
||||||
|
intl.formatMessage({id: 'emoji_gif_picker.dialog.emojis', defaultMessage: 'Emoji Picker'})}
|
||||||
|
aria-modal='true'
|
||||||
>
|
>
|
||||||
<EmojiPickerHeader handleEmojiPickerClose={this.handleEmojiPickerClose}/>
|
<EmojiPickerHeader handleEmojiPickerClose={this.handleEmojiPickerClose}/>
|
||||||
<EmojiPicker
|
<EmojiPicker
|
||||||
@@ -183,3 +199,5 @@ export default class EmojiPickerTabs extends PureComponent<Props, State> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default injectIntl(EmojiPickerTabs);
|
||||||
|
|||||||
@@ -3699,6 +3699,8 @@
|
|||||||
"email_verify.return": "Return to log in",
|
"email_verify.return": "Return to log in",
|
||||||
"email_verify.sending": "Sending email…",
|
"email_verify.sending": "Sending email…",
|
||||||
"email_verify.sent": "Verification email sent",
|
"email_verify.sent": "Verification email sent",
|
||||||
|
"emoji_gif_picker.dialog.emojis": "Emoji Picker",
|
||||||
|
"emoji_gif_picker.dialog.gifs": "GIF Picker",
|
||||||
"emoji_gif_picker.tabs.emojis": "Emojis",
|
"emoji_gif_picker.tabs.emojis": "Emojis",
|
||||||
"emoji_gif_picker.tabs.gifs": "GIFs",
|
"emoji_gif_picker.tabs.gifs": "GIFs",
|
||||||
"emoji_list.actions": "Actions",
|
"emoji_list.actions": "Actions",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user