From 2a657bc85be499f34c10047a7d21fde7e4a550d4 Mon Sep 17 00:00:00 2001
From: tugcekucukoglu <tugcekucukoglu.860@gmail.com>
Date: Fri, 16 Feb 2024 14:42:42 +0300
Subject: [PATCH] Fixed #5293 - aria-invalid state added to Input components

---
 components/lib/autocomplete/AutoComplete.vue         | 2 ++
 components/lib/calendar/Calendar.vue                 | 1 +
 components/lib/cascadeselect/CascadeSelect.vue       | 1 +
 components/lib/checkbox/Checkbox.vue                 | 1 +
 components/lib/chips/Chips.vue                       | 1 +
 components/lib/dropdown/Dropdown.vue                 | 1 +
 components/lib/inputmask/InputMask.vue               | 2 +-
 components/lib/inputnumber/InputNumber.vue           | 1 +
 components/lib/inputswitch/InputSwitch.vue           | 1 +
 components/lib/inputtext/InputText.vue               | 2 +-
 components/lib/multiselect/MultiSelect.vue           | 1 +
 components/lib/radiobutton/RadioButton.vue           | 1 +
 components/lib/textarea/Textarea.vue                 | 2 +-
 components/lib/togglebutton/ToggleButton.vue         | 1 +
 components/lib/tristatecheckbox/TriStateCheckbox.vue | 1 +
 15 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/components/lib/autocomplete/AutoComplete.vue b/components/lib/autocomplete/AutoComplete.vue
index 4310ea5f7..01782561e 100755
--- a/components/lib/autocomplete/AutoComplete.vue
+++ b/components/lib/autocomplete/AutoComplete.vue
@@ -20,6 +20,7 @@
             :aria-expanded="overlayVisible"
             :aria-controls="id + '_list'"
             :aria-activedescendant="focused ? focusedOptionId : undefined"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @keydown="onKeyDown"
@@ -78,6 +79,7 @@
                     :aria-expanded="overlayVisible"
                     :aria-controls="id + '_list'"
                     :aria-activedescendant="focused ? focusedOptionId : undefined"
+                    :aria-invalid="invalid || undefined"
                     @focus="onFocus"
                     @blur="onBlur"
                     @keydown="onKeyDown"
diff --git a/components/lib/calendar/Calendar.vue b/components/lib/calendar/Calendar.vue
index 8c8e884b2..45b15d3ab 100755
--- a/components/lib/calendar/Calendar.vue
+++ b/components/lib/calendar/Calendar.vue
@@ -16,6 +16,7 @@
             :aria-controls="panelId"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             inputmode="none"
             :disabled="disabled"
             :readonly="!manualInput || readonly"
diff --git a/components/lib/cascadeselect/CascadeSelect.vue b/components/lib/cascadeselect/CascadeSelect.vue
index 65f9933b1..07762eaf3 100644
--- a/components/lib/cascadeselect/CascadeSelect.vue
+++ b/components/lib/cascadeselect/CascadeSelect.vue
@@ -18,6 +18,7 @@
                 :aria-expanded="overlayVisible"
                 :aria-controls="id + '_tree'"
                 :aria-activedescendant="focused ? focusedOptionId : undefined"
+                :aria-invalid="invalid || undefined"
                 @focus="onFocus"
                 @blur="onBlur"
                 @keydown="onKeyDown"
diff --git a/components/lib/checkbox/Checkbox.vue b/components/lib/checkbox/Checkbox.vue
index 69eca6f48..d2ae54475 100755
--- a/components/lib/checkbox/Checkbox.vue
+++ b/components/lib/checkbox/Checkbox.vue
@@ -14,6 +14,7 @@
             :required="required"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @change="onChange"
diff --git a/components/lib/chips/Chips.vue b/components/lib/chips/Chips.vue
index 4e3a209fd..f3ab1305f 100755
--- a/components/lib/chips/Chips.vue
+++ b/components/lib/chips/Chips.vue
@@ -44,6 +44,7 @@
                     :style="inputStyle"
                     :disabled="disabled || maxedOut"
                     :placeholder="placeholder"
+                    :aria-invalid="invalid || undefined"
                     @focus="onFocus($event)"
                     @blur="onBlur($event)"
                     @input="onInput"
diff --git a/components/lib/dropdown/Dropdown.vue b/components/lib/dropdown/Dropdown.vue
index 865f7eb07..89b1c682a 100755
--- a/components/lib/dropdown/Dropdown.vue
+++ b/components/lib/dropdown/Dropdown.vue
@@ -19,6 +19,7 @@
             :aria-expanded="overlayVisible"
             :aria-controls="id + '_list'"
             :aria-activedescendant="focused ? focusedOptionId : undefined"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @keydown="onKeyDown"
diff --git a/components/lib/inputmask/InputMask.vue b/components/lib/inputmask/InputMask.vue
index 3ec086167..0733f1b68 100755
--- a/components/lib/inputmask/InputMask.vue
+++ b/components/lib/inputmask/InputMask.vue
@@ -1,5 +1,5 @@
 <template>
-    <input :class="cx('root')" :readonly="readonly" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" v-bind="ptmi('root', ptmParams)" />
+    <input :class="cx('root')" :readonly="readonly" :aria-invalid="invalid || undefined" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" v-bind="ptmi('root', ptmParams)" />
 </template>
 
 <script>
diff --git a/components/lib/inputnumber/InputNumber.vue b/components/lib/inputnumber/InputNumber.vue
index 8a8ba3bad..722e2358d 100755
--- a/components/lib/inputnumber/InputNumber.vue
+++ b/components/lib/inputnumber/InputNumber.vue
@@ -15,6 +15,7 @@
             :placeholder="placeholder"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             @input="onUserInput"
             @keydown="onInputKeyDown"
             @keypress="onInputKeyPress"
diff --git a/components/lib/inputswitch/InputSwitch.vue b/components/lib/inputswitch/InputSwitch.vue
index 0045a4fc3..d6b397a77 100755
--- a/components/lib/inputswitch/InputSwitch.vue
+++ b/components/lib/inputswitch/InputSwitch.vue
@@ -13,6 +13,7 @@
             :aria-checked="checked"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @change="onChange"
diff --git a/components/lib/inputtext/InputText.vue b/components/lib/inputtext/InputText.vue
index 5201d365d..c82884dc1 100755
--- a/components/lib/inputtext/InputText.vue
+++ b/components/lib/inputtext/InputText.vue
@@ -1,5 +1,5 @@
 <template>
-    <input :class="cx('root')" :value="modelValue" @input="onInput" v-bind="getPTOptions('root')" />
+    <input :class="cx('root')" :value="modelValue" :aria-invalid="invalid || undefined" @input="onInput" v-bind="getPTOptions('root')" />
 </template>
 
 <script>
diff --git a/components/lib/multiselect/MultiSelect.vue b/components/lib/multiselect/MultiSelect.vue
index 51dbfa8dd..b0fde821e 100755
--- a/components/lib/multiselect/MultiSelect.vue
+++ b/components/lib/multiselect/MultiSelect.vue
@@ -16,6 +16,7 @@
                 :aria-expanded="overlayVisible"
                 :aria-controls="id + '_list'"
                 :aria-activedescendant="focused ? focusedOptionId : undefined"
+                :aria-invalid="invalid || undefined"
                 @focus="onFocus"
                 @blur="onBlur"
                 @keydown="onKeyDown"
diff --git a/components/lib/radiobutton/RadioButton.vue b/components/lib/radiobutton/RadioButton.vue
index f61388dd4..75d48a17b 100755
--- a/components/lib/radiobutton/RadioButton.vue
+++ b/components/lib/radiobutton/RadioButton.vue
@@ -13,6 +13,7 @@
             :readonly="readonly"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @change="onChange"
diff --git a/components/lib/textarea/Textarea.vue b/components/lib/textarea/Textarea.vue
index 528cab670..2bcc9b601 100755
--- a/components/lib/textarea/Textarea.vue
+++ b/components/lib/textarea/Textarea.vue
@@ -1,5 +1,5 @@
 <template>
-    <textarea :class="cx('root')" :value="modelValue" @input="onInput" v-bind="ptmi('root', ptmParams)"></textarea>
+    <textarea :class="cx('root')" :value="modelValue" :aria-invalid="invalid || undefined" @input="onInput" v-bind="ptmi('root', ptmParams)"></textarea>
 </template>
 
 <script>
diff --git a/components/lib/togglebutton/ToggleButton.vue b/components/lib/togglebutton/ToggleButton.vue
index eaec5a0fc..944f15260 100755
--- a/components/lib/togglebutton/ToggleButton.vue
+++ b/components/lib/togglebutton/ToggleButton.vue
@@ -13,6 +13,7 @@
             :readonly="readonly"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @change="onChange"
diff --git a/components/lib/tristatecheckbox/TriStateCheckbox.vue b/components/lib/tristatecheckbox/TriStateCheckbox.vue
index 66696f802..d2416cafc 100755
--- a/components/lib/tristatecheckbox/TriStateCheckbox.vue
+++ b/components/lib/tristatecheckbox/TriStateCheckbox.vue
@@ -12,6 +12,7 @@
             :readonly="readonly"
             :aria-labelledby="ariaLabelledby"
             :aria-label="ariaLabel"
+            :aria-invalid="invalid || undefined"
             @focus="onFocus"
             @blur="onBlur"
             @change="onChange"