-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
✅ Deploy Preview for papaya-valkyrie-395400 canceled.
|
2cdea3c
to
5cde3fd
Compare
containerRef.current?.querySelector(".vuuList-scrollContainer") ?? | ||
null, | ||
}; | ||
const setContainerRef = useCallback<RefCallback<HTMLDivElement>>((el) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
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; |
There was a problem hiding this comment.
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
}
* fix filter clause editor bur when no suggestions returned * remove unused var
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