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

chore(ui): debounce server requests while typing in filter bar #3470

Merged
merged 5 commits into from
Jan 23, 2025

Conversation

gtarpenning
Copy link
Member

@gtarpenning gtarpenning commented Jan 22, 2025

Description

WB-22888

Debounce typing in the trace table filter bar.

Testing

Prod:
debounce-prod

Branch:
debounce-branch

@gtarpenning gtarpenning marked this pull request as ready for review January 22, 2025 22:36
@gtarpenning gtarpenning requested review from a team as code owners January 22, 2025 22:36
@circle-job-mirror
Copy link

circle-job-mirror bot commented Jan 22, 2025


const debouncedSetFilterModel = useMemo(
() =>
_.debounce((newModel: GridFilterModel) => setFilterModel(newModel), 300),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make constant?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, and I would increase the rate to more like 1 sec

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that adds 1 second of latency to every user though, and 99% probably aren't running into this perf stuff. what about 500ms? @tssweeney

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think 500 is fine, sure. I general this live-filter effect is pretty rare in most applications. Instead there is a moment of "applying" the filter b/c this is so expensive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah true, i'll get the featurebee and you can play with 500

const newModel2 = {...filterModel, items: [item]};
setFilterModel(newModel2);
const newModel2 = {...localFilterModel, items: [item]};
setLocalFilterModel(newModel2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would instead create a callback: updateFilterModel which internally sets the "local" working copy AND calls the debounced one. Seems weird to have the dual call here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this feels wrong, but it would only ever be used in this one place, the other times we setLocalFilterModel we want to either not update the original filter or directly set it instead of using the debounced.

I will try to appease the style gods while not being verbose

Copy link
Collaborator

@tssweeney tssweeney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with comments

@gtarpenning gtarpenning enabled auto-merge (squash) January 23, 2025 17:24
@gtarpenning gtarpenning merged commit e7ab7bf into master Jan 23, 2025
126 of 128 checks passed
@gtarpenning gtarpenning deleted the griffin/debounce-filter branch January 23, 2025 18:19
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants