Skip to content

Commit

Permalink
fix(ModalPage): account for prev expandable value (#6637)
Browse files Browse the repository at this point in the history
* fix(ModalPage): apply DOM changes before height calculation

* fix(ModalPage): apply DOM changes before height calculation
  • Loading branch information
BlackySoul authored Feb 28, 2024
1 parent 3dd9c1c commit c05368c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vkui/src/components/ModalRoot/ModalRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ function initPageModal(modalState: ModalsStateEntry) {
const bottomInsetHeight = bottomInset?.offsetHeight || 0;
const contentHeight = contentElementHeight + bottomInsetHeight;
let prevTranslateY = modalState.translateY;
let prevExpandable = modalState.expandable;

modalState.expandable =
contentHeight > (contentElement?.clientHeight ?? 0) || modalState.settlingHeight === 100;
Expand Down Expand Up @@ -708,11 +709,10 @@ function initPageModal(modalState: ModalsStateEntry) {
hiddenRange = [translateY + 25, translateY + 100];
}

// Свойство expandable может измениться из-за высоты контента, в таком случае на всю высоту не разворачиваем
const shouldExpand = prevExpandable && modalState.expandable;
// Если модалка может открываться на весь экран, и новый сдвиг больше предыдущего, то откроем её на весь экран
if (
(modalState.expandable && translateY > (prevTranslateY ?? 100)) ||
modalState.settlingHeight === 100
) {
if ((shouldExpand && translateY > (prevTranslateY ?? 100)) || modalState.settlingHeight === 100) {
translateY = 0;
}

Expand Down

0 comments on commit c05368c

Please sign in to comment.