Skip to content

Commit 6c7e493

Browse files
committed
fixup! front: Change display when description is too long
1 parent 331478f commit 6c7e493

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

front/src/applications/operationalStudies/components/Scenario/ScenarioDescription.tsx

+2-20
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,13 @@ const ScenarioDescription = ({
2626
const { t } = useTranslation('operationalStudies/scenario');
2727
const { openModal } = useModal();
2828
const [isOpenedDescription, setIsOpenedDescription] = useState<boolean>(false);
29-
const [width, setWidth] = useState<number>(0);
3029
const ref = useRef<HTMLInputElement | null>(null);
3130
const descriptionRef = useRef<HTMLDivElement | null>(null);
3231

33-
const showDescription = () => {
32+
const toggleDescription = () => {
3433
setIsOpenedDescription(!isOpenedDescription);
3534
};
3635

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-
5336
useOutsideClick(descriptionRef, () => setIsOpenedDescription(false));
5437

5538
return (
@@ -66,11 +49,10 @@ const ScenarioDescription = ({
6649
ref={descriptionRef}
6750
title={isOpenedDescription ? '' : scenario.description}
6851
className={`scenario-details-description ${isOpenedDescription ? 'opened' : 'not-opened'}`}
69-
style={{ width: isOpenedDescription ? width + 120 : width }}
7052
>
7153
{scenario.description}
7254
<span
73-
onClick={showDescription}
55+
onClick={toggleDescription}
7456
role="button"
7557
tabIndex={0}
7658
className={isOpenedDescription ? 'displayed-description' : 'display-description'}

front/src/styles/scss/applications/operationalStudies/_scenario.scss

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
0rem 1rem 1.875rem -0.3125rem rgba(0, 0, 0, 0.19),
183183
0rem 0.1875rem 0.3125rem -0.125rem rgba(0, 0, 0, 0.16);
184184
transform: translateX(-0.5rem);
185+
width: calc(100% + 7.5rem);
185186
.displayed-description {
186187
position: absolute;
187188
top: 1rem - 0.3125rem;

0 commit comments

Comments
 (0)