Skip to content

Commit ef2e65f

Browse files
Venkataramanan VenkateswaranVenkataramanan Venkateswaran
authored andcommitted
fix: icon placement inside the dropdown
1 parent 7d91bff commit ef2e65f

2 files changed

Lines changed: 142 additions & 55 deletions

File tree

src/components/WeeklySummariesReport/WeeklySummariesReport.jsx

Lines changed: 102 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,70 @@ const CustomMenuList = props => {
296296
// };
297297
// };
298298

299+
const SaveIndicator = props => {
300+
const { selectProps } = props;
301+
302+
if (!selectProps.showFilterButtons) return null;
303+
304+
return (
305+
<button
306+
type="button"
307+
onMouseDown={e => {
308+
e.preventDefault();
309+
e.stopPropagation();
310+
}}
311+
onClick={e => {
312+
e.preventDefault();
313+
e.stopPropagation();
314+
selectProps.onSaveFilter?.();
315+
}}
316+
title="Save current filter"
317+
aria-label="Save current filter"
318+
className={`${styles.indicatorActionBtn} ${styles.saveIndicatorBtn}`}
319+
>
320+
<i className="fa fa-save" />
321+
</button>
322+
);
323+
};
324+
325+
const ClearSelectionIndicator = props => {
326+
const { selectProps } = props;
327+
328+
if (!selectProps.showFilterButtons) return null;
329+
330+
return (
331+
<button
332+
type="button"
333+
onMouseDown={e => {
334+
e.preventDefault();
335+
e.stopPropagation();
336+
}}
337+
onClick={e => {
338+
e.preventDefault();
339+
e.stopPropagation();
340+
selectProps.onClearSelection?.();
341+
}}
342+
title="Clear selection"
343+
aria-label="Clear selection"
344+
className={`${styles.indicatorActionBtn} ${styles.clearIndicatorBtn}`}
345+
>
346+
<i className="fa fa-times" />
347+
</button>
348+
);
349+
};
350+
351+
const CustomIndicatorsContainer = props => {
352+
const { children } = props;
353+
354+
return (
355+
<components.IndicatorsContainer {...props}>
356+
{children}
357+
<SaveIndicator {...props} />
358+
<ClearSelectionIndicator {...props} />
359+
</components.IndicatorsContainer>
360+
);
361+
};
362+
299363
/* eslint-disable react/function-component-definition */
300364
const WeeklySummariesReport = props => {
301365
const { loading, getInfoCollections } = props;
@@ -2512,8 +2576,7 @@ const WeeklySummariesReport = props => {
25122576
</div>
25132577

25142578
<div>
2515-
{/* MultiSelect with Save/Delete Buttons */}
2516-
<div style={{ position: 'relative' }}>
2579+
<div className={styles.teamCodeSelectRow}>
25172580
{state.teamCodeWarningUsers.length > 0 && (
25182581
<>
25192582
<i
@@ -2522,69 +2585,53 @@ const WeeklySummariesReport = props => {
25222585
data-placement="top"
25232586
data-for="teamCodeWarningTooltip"
25242587
style={{
2525-
position: 'absolute',
2526-
left: '-25px',
2527-
top: '50%',
2528-
transform: 'translateY(-50%)',
25292588
fontSize: '20px',
25302589
cursor: 'pointer',
2590+
marginRight: '8px',
2591+
alignSelf: 'center',
25312592
}}
25322593
/>
25332594
<ReactTooltip id="teamCodeWarningTooltip" place="top" effect="solid">
25342595
{state.teamCodeWarningUsers.length} users have mismatched team codes!
25352596
</ReactTooltip>
25362597
</>
25372598
)}
2538-
<Select
2539-
isMulti
2540-
isSearchable
2541-
closeMenuOnSelect={false}
2542-
hideSelectedOptions={false}
2543-
blurInputOnSelect={false}
2544-
options={state.teamCodes.map(item => {
2545-
const [code, count] = item.label.split(' (');
2546-
return {
2547-
...item,
2548-
label: `${code.padEnd(10, ' ')} (${count}`,
2549-
};
2550-
})}
2551-
value={state.selectedCodes}
2552-
onChange={handleSelectCodeChange}
2553-
components={{
2554-
Option: CheckboxOption,
2555-
MenuList: CustomMenuList,
2556-
}}
2557-
placeholder="Search and select team codes..."
2558-
classNamePrefix="custom-select"
2559-
className={`custom-select-container ${darkMode ? 'dark-mode' : ''} ${
2560-
state.teamCodeWarningUsers.length > 0 ? 'warning-border' : ''
2561-
}`}
2562-
styles={customStyles}
2563-
/>
25642599

2565-
{/* Save/Delete Buttons - only visible when codes are selected */}
2566-
{state.selectedCodes.length > 0 && permissionState.canManageFilter && (
2567-
<div className={styles['filter-save-buttons']}>
2568-
<button
2569-
type="button"
2570-
className={`${styles['filter-save-btn']} ${styles.save}`}
2571-
onClick={() => setCreateFilterModalOpen(true)}
2572-
title="Save current filter"
2573-
aria-label="Save current filter"
2574-
>
2575-
<i className="fa fa-save" />
2576-
</button>
2577-
<button
2578-
type="button"
2579-
className={`${styles['filter-save-btn']} ${styles.clear}`}
2580-
onClick={() => handleSelectCodeChange([])}
2581-
title="Clear selection"
2582-
aria-label="Clear selection"
2583-
>
2584-
<i className="fa fa-times" />
2585-
</button>
2586-
</div>
2587-
)}
2600+
<div className={styles.teamCodeSelect}>
2601+
<Select
2602+
isMulti
2603+
isSearchable
2604+
isClearable
2605+
closeMenuOnSelect={false}
2606+
hideSelectedOptions={false}
2607+
blurInputOnSelect={false}
2608+
options={state.teamCodes.map(item => {
2609+
const [code, count] = item.label.split(' (');
2610+
return {
2611+
...item,
2612+
label: `${code.padEnd(10, ' ')} (${count}`,
2613+
};
2614+
})}
2615+
value={state.selectedCodes}
2616+
onChange={handleSelectCodeChange}
2617+
components={{
2618+
Option: CheckboxOption,
2619+
MenuList: CustomMenuList,
2620+
IndicatorsContainer: CustomIndicatorsContainer,
2621+
}}
2622+
showFilterButtons={
2623+
state.selectedCodes.length > 0 && permissionState.canManageFilter
2624+
}
2625+
onSaveFilter={() => setCreateFilterModalOpen(true)}
2626+
onClearSelection={() => handleSelectCodeChange([])}
2627+
placeholder="Search and select team codes..."
2628+
classNamePrefix="custom-select"
2629+
className={`custom-select-container ${darkMode ? 'dark-mode' : ''} ${
2630+
state.teamCodeWarningUsers.length > 0 ? 'warning-border' : ''
2631+
}`}
2632+
styles={customStyles}
2633+
/>
2634+
</div>
25882635
</div>
25892636
</div>
25902637

src/components/WeeklySummariesReport/WeeklySummariesReport.module.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,46 @@
586586
color: #fff !important;
587587
}
588588

589+
.indicatorActionBtn {
590+
display: flex;
591+
align-items: center;
592+
justify-content: center;
593+
width: 30px;
594+
height: 30px;
595+
margin: 0 4px;
596+
padding: 0;
597+
border: none;
598+
border-radius: 6px;
599+
font-size: 0.9rem;
600+
line-height: 1;
601+
cursor: pointer;
602+
flex-shrink: 0;
603+
}
604+
605+
.indicatorActionBtn i {
606+
margin: 0;
607+
line-height: 1;
608+
pointer-events: none;
609+
}
610+
611+
.saveIndicatorBtn {
612+
background-color: #28a745;
613+
color: white;
614+
}
615+
616+
.saveIndicatorBtn:hover {
617+
background-color: #218838;
618+
}
619+
620+
.clearIndicatorBtn {
621+
background-color: #dc3545;
622+
color: white;
623+
}
624+
625+
.clearIndicatorBtn:hover {
626+
background-color: #c82333;
627+
}
628+
589629
/* The search input field inside the dropdown */
590630
:global(.dark-mode) :global(.dropdown-search) {
591631
background-color: #3b4252 !important;

0 commit comments

Comments
 (0)