Skip to content

Commit

Permalink
add X to clear input
Browse files Browse the repository at this point in the history
  • Loading branch information
OlliL committed Dec 10, 2024
1 parent 4aec37a commit cf80302
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/SelectStandard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
ref="hiddenRef"
v-model="hiddenValue"
/>
<i
class="bi bi-x-lg position-absolute"
style="
right: 32px;
top: 18px;
cursor: pointer;
-webkit-text-stroke: 2px;
"
@click="clearInput"
>
</i>
<input
:class="'form-control dropdown-toggle ' + errorData.inputClass"
style="scroll-margin-top: 56px"
Expand All @@ -21,6 +32,7 @@
@focus="onFocus"
@blur="onBlur"
/>

<div
class="dropdown-menu"
style="max-height: 400px; overflow: scroll"
Expand Down Expand Up @@ -164,6 +176,11 @@ const getFirstDropdownAnchor = () => {
: undefined;
};
const clearInput = () => {
if (fieldValue.value) setState({ touched: true });
hiddenValue.value = undefined;
fieldValue.value = undefined;
};
const setFieldValue = () => {
fieldValue.value = props.selectBoxValues.find(
(sbv) => sbv.id == hiddenValue.value,
Expand Down

0 comments on commit cf80302

Please sign in to comment.