Skip to content

Commit 815f2f9

Browse files
committed
[Dashboard] fix tooltip and control unit filters
1 parent 22dfe1d commit 815f2f9

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

frontend/src/features/Dashboard/components/DashboardForm/ControlUnits/index.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ export function ControlUnits({
7777
dispatch(dashboardActions.setControlUnitsFilters({ key: 'type', value: nextValue }))
7878
}
7979

80+
const hasChildren = !!(controlUnitResults && controlUnitResults?.length > 5)
81+
8082
return (
8183
<div>
8284
<Accordion isExpanded={isExpanded} setExpandedAccordion={setExpandedAccordion} title="Unités">
83-
<Wrapper $hasChildren={!!(controlUnitResults && controlUnitResults?.length > 1)}>
85+
<Wrapper $hasChildren={hasChildren}>
8486
<StyledTextInput
8587
Icon={Icon.Search}
8688
isLabelHidden
@@ -91,10 +93,7 @@ export function ControlUnits({
9193
placeholder="Rechercher une unité"
9294
value={filters?.query}
9395
/>
94-
<SelectFilters
95-
$hasChildren={!!(controlUnitResults && controlUnitResults?.length > 1)}
96-
$isExpanded={isExpanded}
97-
>
96+
<SelectFilters $hasChildren={hasChildren} $isExpanded={isExpanded}>
9897
<StyledSelect
9998
isLabelHidden
10099
isTransparent
@@ -130,13 +129,10 @@ export function ControlUnits({
130129
value={filters?.stationId}
131130
/>
132131
</SelectFilters>
133-
{controlUnitResults && controlUnitResults.length > 0 && (
134-
<ResultList>
135-
{controlUnitResults.map(controlUnit => (
136-
<Item key={controlUnit.id} controlUnit={controlUnit} />
137-
))}
138-
</ResultList>
139-
)}
132+
<ResultList $hasResults={hasChildren}>
133+
{controlUnitResults &&
134+
controlUnitResults.map(controlUnit => <Item key={controlUnit.id} controlUnit={controlUnit} />)}
135+
</ResultList>
140136
</Wrapper>
141137
</Accordion>
142138
<SelectedControlUnits controlUnits={controlUnits} isSelectedAccordionOpen={isSelectedAccordionOpen} />
@@ -150,7 +146,6 @@ const Wrapper = styled.div<{ $hasChildren: boolean }>`
150146
flex-direction: column;
151147
gap: 16px;
152148
padding: 16px 24px;
153-
${({ $hasChildren }) => !$hasChildren && 'padding-bottom: 58px;'}
154149
`
155150

156151
const StyledTextInput = styled(TextInput)`
@@ -179,11 +174,12 @@ const SelectFilters = styled.div<{ $hasChildren: boolean; $isExpanded: boolean }
179174
}}
180175
${({ $hasChildren }) => !$hasChildren && 'position: absolute; margin-top: 41px; width: 27%;'}
181176
`
182-
const ResultList = styled.ul`
177+
const ResultList = styled.ul<{ $hasResults: boolean }>`
183178
display: flex;
184179
flex-direction: column;
185180
gap: 8px;
186181
list-style-type: none;
187182
padding: 0px;
188183
width: 100%;
184+
${({ $hasResults }) => !$hasResults && 'margin-top: 37px;'}
189185
`

frontend/src/features/Dashboard/components/DashboardForm/TerritorialPressure/index.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,20 @@ export function TerritorialPressure({ isExpanded, setExpandedAccordion }: Territ
5959
const department = useAppSelector(state => (activeDashboardId ? state.dashboard.extractedArea?.inseeCode : undefined))
6060

6161
const titleWithTooltip = (
62-
<TitleContainer ref={ref}>
62+
<TitleContainer>
6363
<span>Pression territoriale des contrôles et surveillances</span>
6464
<>
65-
<Icon.Info
66-
aria-describedby="territorialPressureTooltip"
67-
color={THEME.color.slateGray}
68-
onBlur={() => setIsVisibleTooltip(false)}
69-
onFocus={() => setIsVisibleTooltip(true)}
70-
onMouseLeave={() => setIsVisibleTooltip(false)}
71-
onMouseOver={() => setIsVisibleTooltip(true)}
72-
tabIndex={0}
73-
/>
65+
<div ref={ref}>
66+
<Icon.Info
67+
aria-describedby="territorialPressureTooltip"
68+
color={THEME.color.slateGray}
69+
onBlur={() => setIsVisibleTooltip(false)}
70+
onFocus={() => setIsVisibleTooltip(true)}
71+
onMouseLeave={() => setIsVisibleTooltip(false)}
72+
onMouseOver={() => setIsVisibleTooltip(true)}
73+
tabIndex={0}
74+
/>
75+
</div>
7476
{isVisibleTooltip && (
7577
<StyledTooltip $marginLeft={refLeftPosition} id="territorialPressureTooltip" role="tooltip">
7678
Les liens suivants envoient vers des tableaux Metabase montrant la pression territoriale sur les zones REG,
@@ -145,7 +147,7 @@ const StyledTooltip = styled.p<{ $marginLeft: number }>`
145147
font-size: 11px;
146148
padding: 4px 8px;
147149
position: absolute;
148-
left: calc(${p => p.$marginLeft}px + 40px + 310px + 16px);
150+
left: calc(${p => p.$marginLeft}px + 30px);
149151
width: 310px;
150152
z-index: 2;
151153
`

frontend/src/features/Dashboard/components/DashboardForm/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const Container = styled(SideWindowContent)`
202202
// gap and padding are 3px less than the mockup because of box-shadow is hidden because of overflow @see AccordionWrapper
203203
column-gap: 45px;
204204
padding: 21px 21px 0 21px;
205+
overflow: hidden;
205206
`
206207

207208
const Column = styled.div`
@@ -211,7 +212,6 @@ const Column = styled.div`
211212
height: calc(100vh - 48px - 24px); // 48px = navbar height, 24px = padding
212213
scrollbar-gutter: stable;
213214
overflow-y: auto;
214-
215215
padding: 3px;
216216
`
217217
const StyledTextarea = styled(Textarea)`

0 commit comments

Comments
 (0)