Skip to content

Commit 09459d5

Browse files
Merge pull request #670 from A-kirami/feat/click-to-refresh-text-preview
feat(text-preview): add click interaction to force refresh preview
2 parents 75693a9 + 28602e6 commit 09459d5

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.');
@@ -29,6 +30,12 @@ export const TextPreview = (props: any) => {
2930

3031
const Textbox = IMSSTextbox;
3132

33+
const [previewKey, setPreviewKey] = useState<number>(0);
34+
35+
const forcePreviewUpdate = () => {
36+
setPreviewKey((prevKey) => prevKey + 1);
37+
};
38+
3239
const textboxProps = {
3340
textArray: previewTextArray,
3441
isText: true,
@@ -37,7 +44,7 @@ export const TextPreview = (props: any) => {
3744
showName: showNameArray,
3845
currentConcatDialogPrev: '',
3946
fontSize: size,
40-
currentDialogKey: '',
47+
currentDialogKey: String(previewKey),
4148
isSafari: isSafari,
4249
isFirefox: isFirefox,
4350
miniAvatar: '',
@@ -55,6 +62,7 @@ export const TextPreview = (props: any) => {
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}>
6068
<Textbox {...textboxProps} />

0 commit comments

Comments
 (0)