Skip to content

Commit

Permalink
fix(ModalPage): expect number for height (#8209)
Browse files Browse the repository at this point in the history
h2. Описание

Раньше `height` вставлялся в `style`, что позволяло передать без `px`.  С переходом на CSS переменную эта возможность пропала, поэтому проверяем, что `height` это число и добавляем `px`.

- related to #6759

h2. Изменения

Применил `megeStyle` в `style`, чтобы не применять object-spread когда не надо.

h2. Release notes
h2. Исправления
- ModalPage: числовые значения в `height` не приводились к `${height}px`
  • Loading branch information
inomdzhon authored and actions-user committed Jan 29, 2025
1 parent 36b3437 commit e207d80
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vkui/src/components/ModalPage/ModalPageInternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { type ComponentType, type KeyboardEvent, useCallback } from 'react';
import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';
import { mergeStyle } from '../../helpers/mergeStyle';
import { useAdaptivityWithJSMediaQueries } from '../../hooks/useAdaptivityWithJSMediaQueries';
import { useExternRef } from '../../hooks/useExternRef';
import { useVirtualKeyboardState } from '../../hooks/useVirtualKeyboardState';
Expand Down Expand Up @@ -182,11 +183,7 @@ export const ModalPageInternal = ({
desktopMaxWidthClassName,
sizeX === 'regular' && 'vkuiInternalModalPage--sizeX-regular',
)}
style={{
...style,
...desktopMaxWidthStyle,
...getHeightCSSVariable(height),
}}
style={mergeStyle(mergeStyle(desktopMaxWidthStyle, getHeightCSSVariable(height)), style)}
>
<div
{...bottomSheetEventHandlers}
Expand Down Expand Up @@ -241,6 +238,9 @@ function resolveDesktopMaxWidth(

function getHeightCSSVariable(height?: number | string): CSSCustomProperties | undefined {
return height !== undefined
? { '--vkui_internal_ModalPage--userHeight': `${height}` }
? {
'--vkui_internal_ModalPage--userHeight':
typeof height === 'number' ? `${height}px` : height,
}
: undefined;
}

0 comments on commit e207d80

Please sign in to comment.