Skip to content

Commit

Permalink
[PickerInput]: reset scrollTo value on picker close.
Browse files Browse the repository at this point in the history
[VirtualList]: fixed crashes in case of absence of scroll container ref on first mount.
  • Loading branch information
AlekseyManetov committed Oct 1, 2024
1 parent 0a282e3 commit c2480ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions uui-components/src/pickers/hooks/usePickerInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ export function usePickerInput<TItem, TId, TProps>(props: UsePickerInputProps<TI
document.body.style.overflow = !newOpened && modals.length === 0 ? '' : 'hidden';
}

handleDataSourceValueChange({
...dataSourceState,
handleDataSourceValueChange((prevState) => ({
...prevState,
topIndex: 0,
visibleCount: initialRowsVisible,
focusedIndex: 0,
scrollTo: undefined,
search: '',
});
}));

setIsSearchChanged(false);
setOpened(newOpened);
Expand Down
2 changes: 1 addition & 1 deletion uui-core/src/hooks/useVirtualList/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const getRealBottomIndex = ({ rowsCount, scrollContainer, rowOffsets, value: { t
let bottomIndex = topIndex;
const containerScrollTop = scrollContainer?.scrollTop ?? 0;

const containerScrollBottom = containerScrollTop + scrollContainer.clientHeight ?? 0;
const containerScrollBottom = containerScrollTop + scrollContainer?.clientHeight ?? 0;
while (bottomIndex < rowsCount && rowOffsets[bottomIndex] < containerScrollBottom) {
bottomIndex++;
}
Expand Down

0 comments on commit c2480ab

Please sign in to comment.