🐛 Fixed admin crashing when deleting a tier benefit that was last moved (#20628)

ref https://linear.app/tryghost/issue/ENG-1433/
- in the tiers details modal, if a tier was deleted after being moved it
would crash admin

The SortableList component calls renderItem for the drag overlay on the
dragged item. However, if that item was deleted, the draggingId never
got reset causing the drag overlay to try to call renderItem on a
nonexistent item.

As a note, we don't actually use this overlay... it could be best to
strip it out to prevent causing issues.
This commit is contained in:
Steve Larson 2024-07-18 12:18:32 -05:00 committed by GitHub
parent 7c1a732a30
commit 6840c3a6b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -139,7 +139,10 @@ const SortableList = <Item extends {id: string}>({
<div className={`${title && titleSeparator ? '-mt-2' : ''}`}>
<DndContext
collisionDetection={closestCenter}
onDragEnd={event => onMove(event.active.id as string, event.over?.id as string)}
onDragEnd={(event) => {
onMove(event.active.id as string, event.over?.id as string);
setDraggingId(null);
}}
onDragStart={event => setDraggingId(event.active.id as string)}
>
<Wrapper>