Skip to content

Commit 1df0a14

Browse files
Workaround for in-context translation error caused by DOM change (#604)
1 parent f916bbd commit 1df0a14

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/components/PredictedAction.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
*
44
* SPDX-License-Identifier: MIT
55
*/
6-
import { HStack, Text, VisuallyHidden, VStack } from "@chakra-ui/react";
6+
import {
7+
HStack,
8+
Text,
9+
TextProps,
10+
VisuallyHidden,
11+
VStack,
12+
} from "@chakra-ui/react";
713
import debounce from "lodash.debounce";
814
import { useEffect, useMemo, useState } from "react";
915
import { FormattedMessage, useIntl } from "react-intl";
@@ -28,6 +34,15 @@ const PredictedAction = () => {
2834
setLiveRegionEstimatedActionDebounced(estimatedAction);
2935
}, [setLiveRegionEstimatedActionDebounced, estimatedAction]);
3036

37+
const commonEstimatedActionProps: TextProps = {
38+
size: "md",
39+
fontWeight: "bold",
40+
color: predictionResult?.detected ? "brand2.600" : "gray.600",
41+
isTruncated: true,
42+
textAlign: "center",
43+
w: `${predictedActionDisplayWidth}px`,
44+
};
45+
3146
return (
3247
<VStack
3348
className={tourElClassname.estimatedAction}
@@ -63,15 +78,18 @@ const PredictedAction = () => {
6378
isTriggered
6479
/>
6580
</VStack>
81+
{/* Display workaround for in-context translation error caused by DOM change. */}
82+
<Text
83+
{...commonEstimatedActionProps}
84+
display={estimatedAction ? "block" : "none"}
85+
>
86+
{estimatedAction}
87+
</Text>
6688
<Text
67-
size="md"
68-
fontWeight="bold"
69-
color={predictionResult?.detected ? "brand2.600" : "gray.600"}
70-
isTruncated
71-
textAlign="center"
72-
w={`${predictedActionDisplayWidth}px`}
89+
{...commonEstimatedActionProps}
90+
display={estimatedAction ? "none" : "block"}
7391
>
74-
{estimatedAction ?? <FormattedMessage id="unknown" />}
92+
<FormattedMessage id="unknown" />
7593
</Text>
7694
</VStack>
7795
);

0 commit comments

Comments
 (0)