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" ;
713import debounce from "lodash.debounce" ;
814import { useEffect , useMemo , useState } from "react" ;
915import { 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