-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create ModalPopoutPortal to keep previous logic of SplitLayout
In full mode we render Modal/Popout right after content In other modes we render Modal/Popout as a child of the body
- Loading branch information
1 parent
923d880
commit efeeba8
Showing
4 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/vkui/src/components/AppRoot/ModalPopoutPortal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { AppRootContext } from './AppRootContext'; | ||
import { AppRootPortal, type AppRootPortalProps } from './AppRootPortal'; | ||
|
||
/* Специальный компонент для рендеринга ModalRoot и | ||
* popout компонентов внутри SplitLayout после контента | ||
* Как было раньше в v6 при передаче модалок и popout компонентов | ||
* в свойства SplitLayout modal/popout в режиме full */ | ||
export function ModalPopoutPortal(props: AppRootPortalProps) { | ||
const { mode } = React.useContext(AppRootContext); | ||
const usePortalProp = props.usePortal; | ||
|
||
let usePortal: AppRootPortalProps['usePortal'] = usePortalProp; | ||
|
||
const shouldRenderInAppAfterContent = usePortalProp === undefined && mode === 'full'; | ||
if (shouldRenderInAppAfterContent) { | ||
usePortal = 'in-app-after-content'; | ||
} | ||
|
||
return <AppRootPortal {...props} usePortal={usePortal} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters