Skip to content

Commit 43f38c2

Browse files
committed
fix(ui): enhance MultiSelect to display removed items with strikethrough and restore functionality
1 parent 147dfb2 commit 43f38c2

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

src/frontend/submission_form/src/components/multiselect/MultiSelect.js

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,11 @@ const MultiSelect = (props) => {
378378
maxHeight: '350px',
379379
minHeight: 'auto',
380380
overflowY: 'auto',
381-
padding: filteredItems.length === 0 ? '15px' : '8px',
381+
padding: (filteredItems.length === 0 && netRemovals.length === 0) ? '15px' : '8px',
382382
backgroundColor: '#f8f9fa',
383383
boxShadow: 'inset 0 1px 3px rgba(0,0,0,0.08)'
384384
}}>
385-
{filteredItems.length === 0 ? (
385+
{(filteredItems.length === 0 && netRemovals.length === 0) ? (
386386
<div style={{textAlign: 'center', color: '#999'}}>
387387
{props.emptyStateText || `No ${props.itemsNamePlural} found`}
388388
</div>
@@ -393,6 +393,7 @@ const MultiSelect = (props) => {
393393
flexWrap: isVerticalLayout ? 'nowrap' : 'wrap',
394394
gap: isVerticalLayout ? '2px' : '4px'
395395
}}>
396+
{/* Display current items */}
396397
{filteredItems.sort().map((item, index) => {
397398
const isAddedItem = new Set(addedItems).has(item);
398399
const isSelectedForRemoval = selectedForRemoval.has(item);
@@ -403,7 +404,7 @@ const MultiSelect = (props) => {
403404

404405
return (
405406
<span
406-
key={index}
407+
key={`current-${index}`}
407408
style={{
408409
cursor: 'pointer',
409410
margin: '0',
@@ -445,6 +446,55 @@ const MultiSelect = (props) => {
445446
</span>
446447
);
447448
})}
449+
450+
{/* Display removed items with strikethrough */}
451+
{netRemovals.sort().map((item, index) => (
452+
<span
453+
key={`removed-${index}`}
454+
style={{
455+
cursor: 'pointer',
456+
margin: '0',
457+
fontSize: '12px',
458+
fontWeight: '500',
459+
padding: isVerticalLayout ? '4px 8px' : '6px 8px',
460+
display: isVerticalLayout ? 'block' : 'inline-block',
461+
maxWidth: isVerticalLayout ? 'none' : '250px',
462+
width: isVerticalLayout ? '100%' : 'auto',
463+
overflow: 'hidden',
464+
textOverflow: 'ellipsis',
465+
whiteSpace: 'nowrap',
466+
borderRadius: '3px',
467+
backgroundColor: '#ffebee',
468+
border: '1px solid #dc3545',
469+
color: '#721c24',
470+
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
471+
transition: 'all 0.2s ease',
472+
textDecoration: 'line-through',
473+
opacity: 0.8
474+
}}
475+
onClick={() => {
476+
// Re-add the removed item when clicked
477+
props.addItemFunction(item);
478+
}}
479+
title={`${item} (removed - click to restore)`}
480+
onMouseOver={(e) => {
481+
e.target.style.transform = isVerticalLayout ? 'translateX(2px)' : 'translateY(-1px)';
482+
e.target.style.boxShadow = '0 2px 4px rgba(0,0,0,0.1)';
483+
e.target.style.opacity = '1';
484+
}}
485+
onMouseOut={(e) => {
486+
e.target.style.transform = isVerticalLayout ? 'translateX(0)' : 'translateY(0)';
487+
e.target.style.boxShadow = '0 1px 2px rgba(0,0,0,0.05)';
488+
e.target.style.opacity = '0.8';
489+
}}
490+
>
491+
<Glyphicon glyph="minus" style={{marginRight: '6px', fontSize: '11px'}}/>
492+
{(() => {
493+
const displayItem = formatItemDisplay(item);
494+
return isVerticalLayout ? displayItem : (displayItem.length > 30 ? displayItem.substring(0, 30) + '...' : displayItem);
495+
})()}
496+
</span>
497+
))}
448498
</div>
449499
)}
450500
</div>

0 commit comments

Comments
 (0)