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

bug: ion-input debounce is not set with binding syntax on initial load #29374

Closed
3 tasks done
muuvmuuv opened this issue Apr 22, 2024 · 5 comments · Fixed by #29377 · May be fixed by YoutacRandS-VA/eth2-beaconchain-explorer-app#2
Closed
3 tasks done
Labels
package: angular @ionic/angular package type: bug a confirmed bug report

Comments

@muuvmuuv
Copy link

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

Setting debounce value on ion-input to debounce ionInput event has no effect, it triggers immediately.

Expected Behavior

Debounce

Steps to Reproduce

<ion-input
  [debounce]="1200"
  (ionInput)="onInput()"
  type="search"
></ion-input>

Code Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-reckxn?file=src%2Fmain.ts

Ionic Info

See repl

Additional Information

No response

@sean-perkins
Copy link
Contributor

Hello @muuvmuuv thanks for this issue.

This is due to a limitation in how/when angular assigns attributes and when our web components are able to detect the change. Currently the value is bound after the connectedCallback, but before the component is loaded.

As a workaround you can either not use binding syntax for debounce:

<ion-input
  debounce="1200"
  (ionInput)="onInput()"
  type="search"
></ion-input>

or you can update the debounce variable after the component has rendered, such as the ngAfterViewInit lifecycle.

I will log this a a bug, as we have implementation adjustments we can make internally to the component to better handle this scenario.

@sean-perkins sean-perkins changed the title bug: ion-input debounce has no effect bug: ion-input debounce is not set with binding syntax on initial load Apr 23, 2024
@sean-perkins sean-perkins added package: angular @ionic/angular package type: bug a confirmed bug report labels Apr 23, 2024
@ionitron-bot ionitron-bot bot removed the triage label Apr 23, 2024
@muuvmuuv
Copy link
Author

Good point, that works. I don't need to change the value, so this works for my case but I agree, some console warning would be great.

@sean-perkins
Copy link
Contributor

Can you test with this dev-build and let me know if you experience any unwanted behaviors?

npm install @ionic/angular@8.0.1-dev.11713879639.102f51a0

Forked reproduction with dev-build: https://stackblitz.com/edit/stackblitz-starters-wcwcty?file=package.json

@muuvmuuv
Copy link
Author

The dev-build works in our project, even with [debounce]="600". Great @sean-perkins!

@sean-perkins sean-perkins removed their assignment Apr 23, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 23, 2024
…29377)

Issue number: resolves #29374

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

When using Angular binding syntax, the `debounce` value can be set after
`connectedCallback`, but before `componentDidLoad`. This results in the
internal representation of the `debounce` value to be the default and
the watch callback to never fire.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The callback handler for `debounce` is called on component load,
identical to what we do for the same exact reasons for the input `type`.
- `debounce` will correctly reflect and apply the developers value when
using binding syntax on initial load

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev-build: `8.0.1-dev.11713879639.102f51a0`

Forked reproduction with the dev-build is available here:
#29374 (comment)
Copy link

ionitron-bot bot commented May 23, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.