From b12d61a1c6d5f793400ae9ae6f4641c3f3c144b0 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Mon, 5 Dec 2022 15:02:11 +0900
Subject: feat: Support errors, add aria when errors or errorText

---
 code/app/src/lib/components/input.svelte | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'code/app/src/lib/components/input.svelte')

diff --git a/code/app/src/lib/components/input.svelte b/code/app/src/lib/components/input.svelte
index ac01348..80b1543 100644
--- a/code/app/src/lib/components/input.svelte
+++ b/code/app/src/lib/components/input.svelte
@@ -1,6 +1,7 @@
 <script lang="ts">
     import pwKey from "$actions/pwKey";
     import { random_string } from "$lib/helpers";
+    import { error } from "@sveltejs/kit";
     import { ExclamationCircleIcon } from "./icons";
 
     export let label: string | undefined = undefined;
@@ -24,8 +25,8 @@
 
     $: ariaErrorDescribedBy = id + "__" + "error";
     $: attributes = {
-        "aria-describedby": errorText ? ariaErrorDescribedBy : null,
-        "aria-invalid": errorText ? "true" : null,
+        "aria-describedby": errorText || errors?.length ? ariaErrorDescribedBy : null,
+        "aria-invalid": errorText || errors?.length ? "true" : null,
         disabled: disabled || null,
         autocomplete: autocomplete || null,
         required: required || null,
-- 
cgit v1.3

