Skip to content

Commit 57bb0b3

Browse files
committed
feat(text-preview): add click interaction to force refresh preview
1 parent fe65546 commit 57bb0b3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import useTrans from '@/hooks/useTrans';
77
import { getTextSize } from '@/UI/getTextSize';
88
import IMSSTextbox from '@/Stage/TextBox/IMSSTextbox';
99
import { compileSentence } from '@/Stage/TextBox/TextBox';
10+
import { useState } from 'react';
1011

1112
export const TextPreview = (props: any) => {
1213
const t = useTrans('menu.options.pages.display.options.');
@@ -49,15 +50,22 @@ export const TextPreview = (props: any) => {
4950
textboxOpacity: textboxOpacity,
5051
};
5152

53+
const [previewKey, setPreviewKey] = useState<number>(0);
54+
55+
const forcePreviewUpdate = () => {
56+
setPreviewKey((prevKey) => prevKey + 1);
57+
};
58+
5259
return (
5360
<div
5461
className={styles.textPreviewMain}
5562
style={{
5663
background: previewBackground ? `bottom / cover no-repeat url(${previewBackground})` : 'rgba(0, 0, 0, 0.1)',
5764
}}
65+
onClick={forcePreviewUpdate}
5866
>
5967
<div key={`previewTextbox-${textDelay}`} className={styles.textbox}>
60-
<Textbox {...textboxProps} />
68+
<Textbox key={previewKey} {...textboxProps} />
6169
</div>
6270
</div>
6371
);

0 commit comments

Comments
 (0)