3
3
*
4
4
* SPDX-License-Identifier: MIT
5
5
*/
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" ;
7
13
import debounce from "lodash.debounce" ;
8
14
import { useEffect , useMemo , useState } from "react" ;
9
15
import { FormattedMessage , useIntl } from "react-intl" ;
@@ -28,6 +34,15 @@ const PredictedAction = () => {
28
34
setLiveRegionEstimatedActionDebounced ( estimatedAction ) ;
29
35
} , [ setLiveRegionEstimatedActionDebounced , estimatedAction ] ) ;
30
36
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
+
31
46
return (
32
47
< VStack
33
48
className = { tourElClassname . estimatedAction }
@@ -63,15 +78,18 @@ const PredictedAction = () => {
63
78
isTriggered
64
79
/>
65
80
</ 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 >
66
88
< 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" }
73
91
>
74
- { estimatedAction ?? < FormattedMessage id = "unknown" /> }
92
+ < FormattedMessage id = "unknown" />
75
93
</ Text >
76
94
</ VStack >
77
95
) ;
0 commit comments