Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ion-input clear function #628

Open
dt2patel opened this issue Jan 16, 2025 · 3 comments
Open

Use ion-input clear function #628

dt2patel opened this issue Jan 16, 2025 · 3 comments
Assignees

Comments

@dt2patel
Copy link
Contributor

dt2patel commented Jan 16, 2025

Why not use default ion-input clear function? is it because we need to set the value to 0?

<ion-input :label="translate('Count')" :disabled="productStoreSettings['forceScan']" :placeholder="translate('submit physical count')" name="value" v-model="inputCount" id="value" type="number" min="0" required @ionInput="hasUnsavedChanges=true" @keydown="inputCountValidation"/>
<ion-button slot="end" fill="clear" size="default" class="ion-no-padding" @click="inputCount = 0">
<ion-icon :icon="closeOutline" stot="icon-only" />

@dt2patel dt2patel moved this from 📋 Backlog to 📅 Planned in Digital Experience Platform Jan 16, 2025
@priyanshee1604 priyanshee1604 moved this from 📅 Planned to 👀 In review in Digital Experience Platform Jan 24, 2025
@priyanshee1604 priyanshee1604 moved this from 👀 In review to 🏗 In progress in Digital Experience Platform Jan 24, 2025
@priyanshee1604
Copy link
Contributor

The default clear functionality of ion-input simply clears the field, leaving it blank. However, in this case, the desired behavior is to reset inputCount to 0 rather than leaving it empty. Therefore, the default ion-input clear function was not used.

@dt2patel
Copy link
Contributor Author

Is it possible to alter the function of the default clear button instead? That way the UI would be cleaner

@priyanshee1604
Copy link
Contributor

priyanshee1604 commented Jan 31, 2025

It is possible to override the default behavior of the ion-input clear button, but it requires additional handling, as detailed below:

  1. Value checks need to be applied for the ionInput event, as no dedicated event is triggered when the clear function of ion-input is used.
  2. Vue's nextTick functionality is necessary to handle the edge case where the user clicks the clear button twice in quick succession after the value has been changed to 0.
  3. Despite these measures, the input remains stuck with the value "0," preventing further input.
  4. Due to the nextTick functionality, the "0" persists, and the user will have to manually append the count after 0, such as "012," "037," and so on.

@priyanshee1604 priyanshee1604 moved this from 🏗 In progress to 📅 Planned in Digital Experience Platform Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📅 Planned
Development

No branches or pull requests

2 participants