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

fix https://github.com/rpbouman/huey/issues/360 #418

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/PivotTableUi/PivotTableUi.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
this is to prevent scroll events from being generated while the pivot table is updating
https://github.com/rpbouman/huey/issues/360
*/
pointer-events: none;

> .pivotTableUiTable {

/*
Expand Down
16 changes: 11 additions & 5 deletions src/PivotTableUi/PivotTableUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ class PivotTableUi extends EventEmitter {
this,
timeoutCallback
);
//queryModel.addEventListener('change', this.#queryModelChangeHandler.bind(this));
}

#initScrollHandler(){
Expand Down Expand Up @@ -294,6 +293,7 @@ class PivotTableUi extends EventEmitter {
var queryModelStateAfterChange = this.#queryModel.getState({includeItemIndices: true});
var stateAfter = JSON.stringify(queryModelStateAfterChange);
if (stateBefore === stateAfter){
this.#queryModelStateBeforeChange = undefined;
return;
}
var queryModelStateBeforeChange = JSON.parse(stateBefore);
Expand Down Expand Up @@ -393,13 +393,14 @@ class PivotTableUi extends EventEmitter {
this.#setNeedsUpdate(needsUpdate);

if (!this.#autoUpdate){
this.#queryModelStateBeforeChange = undefined;
return;
}

if (needsUpdate){
await this.updatePivotTableUi();
}

this.#queryModelStateBeforeChange = undefined;
}

#setBusy(busy){
Expand Down Expand Up @@ -436,6 +437,11 @@ class PivotTableUi extends EventEmitter {
async #handleInnerContainerScrolled(event, count){
if (count === undefined){
// this is the last scroll event, update the table contents.
if (this.#queryModelStateBeforeChange){
// if the table is scrolled while it is being changed, don't entertain the scroll request.
// https://github.com/rpbouman/huey/issues/360
return;
}
try {
this.#setBusy(true);
await this.#updateDataToScrollPosition();
Expand All @@ -448,14 +454,14 @@ class PivotTableUi extends EventEmitter {
error: error
});
}
setTimeout(this.#setBusy.bind(this), 1);
finally {
setTimeout(this.#setBusy.bind(this), 1);
}
}
else
if (count !== 0) {
return;
}
// this is the first scroll event, set the busy indicator
this.getDom().setAttribute('aria-busy', String(true));
}

#getPhysicalTupleIndices(){
Expand Down