Topic: Cleaning the edit form (#3418)

This commit is contained in:
Alexander Zinchuk 2023-07-05 13:14:15 +02:00
parent a5ebc78d39
commit c76e73b047
2 changed files with 15 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import React, {
memo, useCallback, useMemo, useState,
memo, useCallback, useEffect, useMemo, useState,
} from '../../lib/teact/teact';
import { getActions, withGlobal } from '../../global';
@ -60,6 +60,13 @@ const CreateTopic: FC<OwnProps & StateProps> = ({
onBack: onClose,
});
useEffect(() => {
if (!isActive) {
setTitle('');
setIconEmojiId(undefined);
}
}, [isActive]);
const handleTitleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
setTitle(e.target.value);
}, []);

View File

@ -61,6 +61,13 @@ const EditTopic: FC<OwnProps & StateProps> = ({
onBack: onClose,
});
useEffect(() => {
if (!isActive) {
setTitle('');
setIconEmojiId(undefined);
}
}, [isActive]);
useEffect(() => {
if (topic?.title || topic?.iconEmojiId) {
setTitle(topic.title);