Skip to content

Commit

Permalink
Merge pull request #15114 from Budibase/snippets-fix
Browse files Browse the repository at this point in the history
prevent empty snippets being saved, don't crash for old empty snippets
  • Loading branch information
shogunpurple authored Dec 3, 2024
2 parents 5f28689 + 92e5667 commit 188c403
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
if (!name?.length) {
return "Name is required"
}
if (snippets.some(snippet => snippet.name === name)) {
if (!snippet?.name && snippets.some(snippet => snippet.name === name)) {
return "That name is already in use"
}
if (firstCharNumberRegex.test(name)) {
Expand Down Expand Up @@ -106,11 +106,7 @@
Delete
</Button>
{/if}
<Button
cta
on:click={saveSnippet}
disabled={!snippet && (loading || nameError)}
>
<Button cta on:click={saveSnippet} disabled={!code || loading || nameError}>
Save
</Button>
</svelte:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<div class="snippet-popover">
{#key hoveredSnippet}
<CodeEditor
value={hoveredSnippet.code.trim()}
value={hoveredSnippet.code?.trim()}
mode={EditorModes.JS}
readonly
/>
Expand Down

0 comments on commit 188c403

Please sign in to comment.