MM-51676 - korean chars create duplicate categories (#23839)
* MM-51676 - korean chars create duplicate categories * use isProcessing as a property instead of state; move validation of isComposing to generic modal
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8fe4c5376f
Коммит
af3b70b606
@@ -16,6 +16,7 @@ import {localizeMessage} from 'utils/utils';
|
|||||||
import '../category_modal.scss';
|
import '../category_modal.scss';
|
||||||
|
|
||||||
const MAX_LENGTH = 22;
|
const MAX_LENGTH = 22;
|
||||||
|
const ACTION_WAIT_MS = 1000;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onExited: () => void;
|
onExited: () => void;
|
||||||
@@ -34,6 +35,8 @@ type State = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class EditCategoryModal extends React.PureComponent<Props, State> {
|
export default class EditCategoryModal extends React.PureComponent<Props, State> {
|
||||||
|
timeoutId: NodeJS.Timeout | null = null;
|
||||||
|
isProcessing = false;
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@@ -54,7 +57,21 @@ export default class EditCategoryModal extends React.PureComponent<Props, State>
|
|||||||
this.handleClear();
|
this.handleClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.timeoutId) {
|
||||||
|
clearTimeout(this.timeoutId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleConfirm = () => {
|
handleConfirm = () => {
|
||||||
|
if (this.isProcessing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.isProcessing = true;
|
||||||
|
this.timeoutId = setTimeout(() => {
|
||||||
|
this.isProcessing = false;
|
||||||
|
}, ACTION_WAIT_MS);
|
||||||
|
|
||||||
if (this.props.categoryId) {
|
if (this.props.categoryId) {
|
||||||
this.props.actions.renameCategory(this.props.categoryId, this.state.categoryName);
|
this.props.actions.renameCategory(this.props.categoryId, this.state.categoryName);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import React from 'react';
|
|||||||
|
|
||||||
type Modal = {
|
type Modal = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
dialogProps: Record<string, any>;
|
|
||||||
dialogType: React.ComponentType;
|
dialogType: React.ComponentType;
|
||||||
|
dialogProps?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -64,7 +64,7 @@ export default class ModalController extends React.PureComponent<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>{modalOutput}</>
|
modalOutput
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ export class GenericModal extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
private onEnterKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
private onEnterKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
|
if (event.nativeEvent.isComposing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.props.autoCloseOnConfirmButton) {
|
if (this.props.autoCloseOnConfirmButton) {
|
||||||
this.onHide();
|
this.onHide();
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user