Skip to content

Commit

Permalink
Dialog.Modal: add useMemo, formated
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytroshch committed Aug 24, 2023
1 parent 3b51095 commit fb481ac
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/core/src/components/ui/Dialog/Dialog.Modal.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import cx from 'classnames'
import FocusTrap from 'focus-trap-react'
import PropTypes from 'prop-types'
import React, { forwardRef, useRef } from 'react'
import React, { forwardRef, useMemo, useRef } from 'react'

import * as Classes from '../../../common/classes'
import { DIALOG_CONTAINER_ID } from './Dialog.constants'
import * as Classes from '../../../common/classes'

Check failure on line 7 in packages/core/src/components/ui/Dialog/Dialog.Modal.js

View workflow job for this annotation

GitHub Actions / checks (14.x)

`../../../common/classes` import should occur before import of `./Dialog.constants`

Check failure on line 7 in packages/core/src/components/ui/Dialog/Dialog.Modal.js

View workflow job for this annotation

GitHub Actions / checks (14.x)

`../../../common/classes` import should occur before import of `./Dialog.constants`

const Modal = forwardRef(({
state,
Expand All @@ -24,6 +24,13 @@ const Modal = forwardRef(({
style,
}, ref) => {
const titleRef = useRef()
const modalStyle = useMemo(() => ({
maxWidth: width,
height,
textAlign,
...style,
}), [width, height, textAlign, style])

return (
/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
<FocusTrap
Expand All @@ -48,9 +55,7 @@ const Modal = forwardRef(({
'is-mobile-fullscreen': isFullscreenInMobile,
})}
ref={ref}
style={{
maxWidth: width, height, textAlign, ...style,
}}
style={modalStyle}
>
{title && (
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
Expand Down

0 comments on commit fb481ac

Please sign in to comment.