Skip to content

Global filter string do not get updated if initial value is passed in. #661

Description

@SparshithNR
  • I'm submitting a ...

  • What is the current behavior?
    The globalFilter do not get updated when consumer of EMT passes filterString case, because of when the get filterString is evaluated the this.args.filterString always exists. So we can never get the updated value in the filterString
    filter_string

Note: This is the same case for all the places where local tracked variable is used for tracking the state.

pull the change or make the same changes to local clone from above. Visit: http://localhost:4201/#/examples/block-usage

Try to update the string.
Put a debugger at the get and set for the filterString.
https://github.com/SparshithNR/ember-models-table/blob/9a501ab8fb5a59135000278039f1c584d9155b5d/addon/components/models-table.ts#L334-L341

  • [Bug] What is the expected behavior?
    The filterString updates

  • [Feature] What is the motivation / use case for changing the behavior?

none

  • [Support] What exactly you try to do?
    none

  • Please tell us about your environment:

  • ember-models-table version: any version
  • ember version: any version
  • ember-data version: any version
  • ember-cli version: any version
  • node version: any version
  • npm or yarn version: any version
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
  • The fix is to change the how _filterString is being setup.
 @tracked 
 protected _filterString = this.args.filterString ?? ''; 
 protected get filterString(): string { 
   return this._filterString; 
 } 
 protected set filterString(v: string) { 
   this._filterString = v; 
 } 

or

 @trackedReset('args.filterString')
 protected _filterString = this.args.filterString ?? ''; 
 protected get filterString(): string { 
   return this._filterString; 
 } 
 protected set filterString(v: string) { 
   this._filterString = v; 
 } 

Activity

  1. onechiporenko commented on Sep 15, 2024

    @onechiporenko
    Owner

    Hello, @SparshithNR
    onDisplayDataChanged-action should be used to update initial values for fields like filterString, currentPageNumber, pageSize etc.
    Please check sources of https://onechiporenko.github.io/ember-models-table/v.5/plain-html/#/examples/query-params

  2. SparshithNR commented on Sep 16, 2024

    @SparshithNR
    Author

    So the idea is if value is passed in once, the consumer of EMT is responsible to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions