From 31f929269f566586d2fe5ad3bf19597ec0fdab82 Mon Sep 17 00:00:00 2001 From: estib Date: Thu, 10 Oct 2024 10:14:41 +0200 Subject: [PATCH] fix: Commit Input: Update the typing of the text areas Update the typing of the text areas components inside the commit message input component. Also add guards against them being undefined --- .../src/lib/commit/CommitMessageInput.svelte | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/lib/commit/CommitMessageInput.svelte b/apps/desktop/src/lib/commit/CommitMessageInput.svelte index 39f6d66e5..ed70b3204 100644 --- a/apps/desktop/src/lib/commit/CommitMessageInput.svelte +++ b/apps/desktop/src/lib/commit/CommitMessageInput.svelte @@ -52,8 +52,8 @@ let aiLoading = false; let aiConfigurationValid = false; - let titleTextArea: HTMLTextAreaElement; - let descriptionTextArea: HTMLTextAreaElement; + let titleTextArea: HTMLTextAreaElement | undefined; + let descriptionTextArea: HTMLTextAreaElement | undefined; $: ({ title, description } = splitMessage(commitMessage)); $: valid = !!title; @@ -138,7 +138,7 @@ if (e.key === KeyName.Delete && value.length === 0) { e.preventDefault(); if (titleTextArea) { - titleTextArea?.focus(); + titleTextArea.focus(); titleTextArea.selectionStart = titleTextArea.textLength; } autoHeight(e.currentTarget); @@ -178,9 +178,11 @@ : `${toMove}\n${description}`; commitMessage = concatMessage(toKeep, newDescription); tick().then(() => { - descriptionTextArea?.focus(); - descriptionTextArea.setSelectionRange(0, 0); - autoHeight(descriptionTextArea); + if (descriptionTextArea) { + descriptionTextArea.focus(); + descriptionTextArea.setSelectionRange(0, 0); + autoHeight(descriptionTextArea); + } }); }