This method allows you to close a previously opened modal window. The main usage place is the confirm/cancel buttons inside the modal windows.
Platforms
- B2B-Web
Method params
Parameter name | Parameter type | Required | Parameter description |
---|---|---|---|
modalId | string | yes | ID of the modal window to be closed |
Return value
If successful, the method will return a JSON object containing a single
success
field:json{ "success": true }
Usage examples
Below is an example of closing a modal window from the modal window itself:
typescript// pages/modal.tsx import { useRouter } from 'next/router' import React, { useCallback } from 'react' import bridge from '@open-condo/bridge' import { Typography, Space, Button } from '@open-condo/ui' export default function SuccessPage (): React.ReactNode { const { query: { modalId } } = useRouter() const closeModal = useCallback(() => { if (modalId && !Array.isArray(modalId)) { bridge.send('CondoWebAppCloseModalWindow', { modalId }) } }, [modalId]) return ( <Space direction='vertical' size={40}> <Typography.Text> This will drop your database. Do you want to continue? </Typography.Text> <Space direction='horizontal' size={16}> <Button type='secondary' danger onClick={closeModal}>Ok</Button> <Button type='secondary' onClick={closeModal}>Cancel</Button> </Space> </Space> ) }
