Skip to content

fix(table): prevent duplicate lazy load emission when filter on input - #1753

Open
faried-elrewany wants to merge 1 commit into
openng-org:mainfrom
faried-elrewany:fix/table-lazy-load-double-emit
Open

faried-elrewany wants to merge 1 commit into
openng-org:mainfrom
faried-elrewany:fix/table-lazy-load-double-emit

Conversation

@faried-elrewany

Copy link
Copy Markdown

Description

When <p-columnFilter> is configured with [filterOn]="'input'", typing triggers onModelChange(), which immediately calls dataTable._filter(). Pressing Enter subsequently fired onTextInputEnterKeyDown or onNumericInputKeyDown, which unconditionally invoked dataTable._filter() a second time, resulting in duplicate onLazyLoad event emissions.

Changes:

  • Guarded onTextInputEnterKeyDown and onNumericInputKeyDown in ColumnFilterFormElement to bypass _filter() when filterOn === 'input'.
  • Preserved standard Enter key filtering behavior when filterOn === 'enter'.
  • Added unit test coverage verifying a single onLazyLoad emission across text and numeric filters.

Related issues

Fixes #884

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes the public API)
  • Documentation only
  • Refactor, test, or chore (no user-facing change)

Breaking changes

None

Test plan

  • npm test (ran pnpm --filter @openng/optimus-ui test:unit - 3 new tests passed)
  • npm run lint (npx eslint passed with 0 errors)
  • Verified unit tests covering both text and numeric lazy filter double-emission scenarios.

Checklist

  • Issue discussed or bug clearly described (link issue when applicable)
  • Tests added or updated for behavioral changes
  • Documentation updated (README, JSDoc, migration notes as needed)
  • Public API changes documented; breaking changes called out
  • CHANGELOG updated (if the repository maintains one and the change is user-facing)
  • Commit messages follow Conventional Commits
  • I agree to follow the OpenNG Foundation Code of Conduct

Additional context

Prevents unnecessary backend network roundtrips triggered by duplicate onLazyLoad emissions on server-side paginated/filtered tables.

When <p-columnFilter> is configured with [filterOn]="'input'", typing
triggers onModelChange() which immediately calls dataTable._filter().
Pressing Enter subsequently fired onTextInputEnterKeyDown or
onNumericInputKeyDown, which unconditionally invoked dataTable._filter()
a second time.

Guarded both keydown handlers in ColumnFilterFormElement to skip
_filter() when filterOn === 'input', preserving standard Enter key
behavior when filterOn === 'enter'.

Fixes openng-org#884
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.

p-table : triggers lazy loading event twice whenever a new value is entered into a filter

1 participant