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 filter clause editor bug when no suggestions returned #1174

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

heswell
Copy link
Contributor

@heswell heswell commented Jan 30, 2024

fix bug encountered in FilterClauseEditor when typeahead service returns no suggestions
allow data to be typed and ENTER pressed to continue when typing text into combobox in filters
fix issues in list/combobox/dropdown keyboard navigation and enable more of the combobox tests
remove VirtualizedList. Not used and if we need this we will use Table
rename a couple of Filter components to avoid confusion with more generic components

Copy link

netlify bot commented Jan 30, 2024

Deploy Preview for papaya-valkyrie-395400 canceled.

Name Link
🔨 Latest commit 5cde3fd
🔍 Latest deploy log https://app.netlify.com/sites/papaya-valkyrie-395400/deploys/65b97291aace0b0008c95c1c

@heswell heswell force-pushed the filter-bar-dropdown-to-combo branch from 2cdea3c to 5cde3fd Compare January 30, 2024 22:05
@heswell heswell requested a review from junaidzm13 January 30, 2024 22:05
@heswell heswell changed the title fix filter clause editor bur when no suggestions returned fix filter clause editor bug when no suggestions returned Jan 30, 2024
containerRef.current?.querySelector(".vuuList-scrollContainer") ??
null,
};
const setContainerRef = useCallback<RefCallback<HTMLDivElement>>((el) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the crux of the List navigation fix. The problem was that some of the navigation functions rely on the containerRef being set. Because of the way list renders, a child of MeasuredItem, the containerRef , defined as a regular RefObject, was only set on second render. If navigation happens immediately, the ref was not yet set.

By using a RefCallback, we ensure that the refs are set immediately the List is rendered.

Copy link
Contributor

@junaidzm13 junaidzm13 left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines 121 to +136
const newScrollTop = Math.max(scrollTop - clientHeight, 0);
if (newScrollTop !== scrollTop && index > 0) {
if (newScrollTop === scrollTop && index > 0) {
return 0;
} else if (newScrollTop !== scrollTop && index > 0) {
containerEl.scrollTo(0, newScrollTop);
return new Promise((resolve) => {
// We must defer this operation until after render. If Items are virtualized.
// we need to allow them to be rendered.
requestAnimationFrame(() => {
let nextIdx = index;
let nextRect;
do {
nextIdx -= 1;
nextRect = getElementByDataIndex(
containerEl,
nextIdx,
true
).getBoundingClientRect();
} while (nextRect.top > itemTop && nextIdx > 0);
resolve(nextIdx);
});
});
let nextIdx = index;
let nextRect;
do {
nextIdx -= 1;
nextRect = getElementByDataIndex(
containerEl,
nextIdx,
true
).getBoundingClientRect();
} while (nextRect.top > itemTop && nextIdx > 0);
return nextIdx;
Copy link
Contributor

@junaidzm13 junaidzm13 Jan 31, 2024

Choose a reason for hiding this comment

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

Unrelated to this change (for the future) ->

the flow would be easier to follow if we can have a separate function to calculate the next index. For example:

if (index > 0) {
  if (newScrollTop === scrollTop) {
    return 0;
  } else  {
    containerEl.scrollTo(0, newScrollTop);
    return next-idx-fn(); // should have a better name obv
}

@heswell heswell merged commit f4c2d61 into main Jan 31, 2024
16 checks passed
rumakt pushed a commit to rumakt/vuu that referenced this pull request Feb 15, 2024
* fix filter clause editor bur when no suggestions returned

* remove unused var
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.

2 participants