@@ -26,30 +26,13 @@ const ScenarioDescription = ({
26
26
const { t } = useTranslation ( 'operationalStudies/scenario' ) ;
27
27
const { openModal } = useModal ( ) ;
28
28
const [ isOpenedDescription , setIsOpenedDescription ] = useState < boolean > ( false ) ;
29
- const [ width , setWidth ] = useState < number > ( 0 ) ;
30
29
const ref = useRef < HTMLInputElement | null > ( null ) ;
31
30
const descriptionRef = useRef < HTMLDivElement | null > ( null ) ;
32
31
33
- const showDescription = ( ) => {
32
+ const toggleDescription = ( ) => {
34
33
setIsOpenedDescription ( ! isOpenedDescription ) ;
35
34
} ;
36
35
37
- useEffect ( ( ) => {
38
- const handleResize = ( ) => {
39
- if ( ref . current ) {
40
- setWidth ( ref . current . offsetWidth ) ;
41
- }
42
- } ;
43
-
44
- handleResize ( ) ;
45
-
46
- window . addEventListener ( 'resize' , handleResize ) ;
47
-
48
- return ( ) => {
49
- window . removeEventListener ( 'resize' , handleResize ) ;
50
- } ;
51
- } , [ ] ) ;
52
-
53
36
useOutsideClick ( descriptionRef , ( ) => setIsOpenedDescription ( false ) ) ;
54
37
55
38
return (
@@ -66,11 +49,10 @@ const ScenarioDescription = ({
66
49
ref = { descriptionRef }
67
50
title = { isOpenedDescription ? '' : scenario . description }
68
51
className = { `scenario-details-description ${ isOpenedDescription ? 'opened' : 'not-opened' } ` }
69
- style = { { width : isOpenedDescription ? width + 120 : width } }
70
52
>
71
53
{ scenario . description }
72
54
< span
73
- onClick = { showDescription }
55
+ onClick = { toggleDescription }
74
56
role = "button"
75
57
tabIndex = { 0 }
76
58
className = { isOpenedDescription ? 'displayed-description' : 'display-description' }
0 commit comments