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

Clear search input fix #430

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pavelpugachh
Copy link

@pavelpugachh pavelpugachh commented Jul 27, 2023

Clear search input only if value exists not to trigger valueChanges

Clear search input only if value exists
Update mat-select-search.component.ts
@melroy89
Copy link
Contributor

As long as we don't cause regression on my code I'm fine with it. :P

this.transaction_ledger_id_filter.valueChanges
.pipe(
  tap(() => (this.searching = true)),
  takeUntil(this.onDestroy),
  debounceTime(100),
  switchMap((search) => {
    if (search) {
      return this.ledgerService.search(search)
    } else {
      if (this.transaction.transaction_ledger_id) {
        return this.ledgerService.getOne(this.transaction.transaction_ledger_id).pipe(map((ledger) => [ledger]))
      } else {
        return this.ledgerService.getAll()
      }
    }
  }),
  takeUntil(this.onDestroy)
)
.subscribe({
  next: (filteredLegers) => {
    this.searching = false
    this.ledgers.next(filteredLegers)
  },
  error: (error) => {
    console.error(error)
    this.searching = false
  }
})

@macjohnny
Copy link
Member

Its unclear to me why this is needed.
@pavelpugachh can you elaborate the scenario this fixes?

@pavelpugachh
Copy link
Author

pavelpugachh commented Apr 22, 2024 via email

@macjohnny
Copy link
Member

@pavelpugachh thanks for the explanation. i would suggest to move the check to the _reset method, wdyt?

@pavelpugachh
Copy link
Author

pavelpugachh commented Apr 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants