Skip to content

Commit

Permalink
fix: unnecessary first saving of the draft trigger by the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dhavaldodiya committed Oct 23, 2023
1 parent 023f0c8 commit 6ee0f77
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import React, { FC, SyntheticEvent, useMemo } from 'react';
import React, { FC, SyntheticEvent, useMemo, useState } from 'react';

import { Container } from '@zextras/carbonio-design-system';
import { useIntegratedComponent, useUserSettings } from '@zextras/carbonio-shell-ui';
Expand Down Expand Up @@ -38,6 +38,7 @@ export const TextEditorContainer: FC<TextEditorContainerProps> = ({
disabled
}) => {
const [Composer, composerIsAvailable] = useIntegratedComponent('composer');
const [isFirstChangeEventFired, setIsFirstChangeEventFired] = useState(false);

const { prefs } = useUserSettings();
const defaultFontFamily = useMemo<string>(
Expand Down Expand Up @@ -73,7 +74,9 @@ export const TextEditorContainer: FC<TextEditorContainerProps> = ({
disabled={disabled}
onFileSelect={onFilesSelected}
onEditorChange={(ev: [string, string]): void => {
onContentChanged({ plainText: ev[0], richText: ev[1] });
if (isFirstChangeEventFired)
onContentChanged({ plainText: ev[0], richText: ev[1] });
setIsFirstChangeEventFired(true);
}}
onDragOver={onDragOver}
customInitOptions={composerCustomOptions}
Expand Down

0 comments on commit 6ee0f77

Please sign in to comment.