Skip to content

Commit 06e26b0

Browse files
AlexVOiceoverclaude
andcommitted
fix(actions): implement proper null safety for action IDs
- Only show edit/delete buttons for actions with valid IDs - Prevent startEdit from processing actions without IDs - Use non-null assertion operator only after ID existence check - Eliminates potential empty string parameter issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5b50359 commit 06e26b0

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/lib/components/ui/ActionsCRUD.svelte

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
}
7878
7979
function startEdit(action: Action) {
80-
editingActionId = action.id || null;
80+
if (!action.id) return; // Don't edit actions without IDs
81+
editingActionId = action.id;
8182
editDescription = action.description || '';
8283
}
8384
@@ -185,20 +186,24 @@
185186
{/if}
186187
</div>
187188
<div class="action-buttons">
188-
<button
189-
onclick={() => startEdit(action)}
190-
class="btn btn-sm"
191-
aria-label="Edit action"
192-
>
193-
Edit
194-
</button>
195-
<button
196-
onclick={() => confirmDelete(action.id || '')}
197-
class="btn btn-sm btn-error"
198-
aria-label="Delete action"
199-
>
200-
Delete
201-
</button>
189+
{#if action.id}
190+
<button
191+
onclick={() => startEdit(action)}
192+
class="btn btn-sm"
193+
aria-label="Edit action"
194+
>
195+
Edit
196+
</button>
197+
{/if}
198+
{#if action.id}
199+
<button
200+
onclick={() => confirmDelete(action.id!)}
201+
class="btn btn-sm btn-error"
202+
aria-label="Delete action"
203+
>
204+
Delete
205+
</button>
206+
{/if}
202207
</div>
203208
</div>
204209
{/if}

0 commit comments

Comments
 (0)