Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ui-dialog/src/Dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Dialog extends Component<DialogProps> {
role === 'dialog' && this.props.shouldContainFocus ? true : undefined
}
className={this.props.className} // TODO in V2 remove className, there is no usage of it.
style={{ borderRadius: 'inherit' }} // ensure the dialog inherits border radius from View
style={{ borderRadius: 'inherit', ...this.props.style }} // ensure the dialog inherits border radius from View
ref={this.getRef}
>
{this.props.children}
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-dialog/src/Dialog/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type DialogOwnProps = {
*/
as?: AsElementType
display?: 'auto' | 'block' | 'inline-block'
/**
* Inline styles applied to the root element. Merged with the default
* `borderRadius: inherit` so consumers can override it.
*/
style?: React.CSSProperties
/**
* The aria-label to read for screen reader. When specified, it will automatically set role="dialog".
*/
Expand Down Expand Up @@ -77,7 +82,8 @@ const allowedProps: AllowedPropKeys = [
'shouldCloseOnDocumentClick',
'shouldCloseOnEscape',
'shouldFocusOnOpen',
'elementRef'
'elementRef',
'style'
]

export type { DialogProps }
Expand Down
27 changes: 15 additions & 12 deletions packages/ui-modal/src/Modal/v2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Modal extends Component<ModalProps, ModalState> {
transitioning: false,
open: props.open ?? false,
windowHeight: 99999,
windowWidth: 99999,
bodyScrollAriaLabel: undefined
}
}
Expand All @@ -99,7 +100,7 @@ class Modal extends Component<ModalProps, ModalState> {

componentDidMount() {
this.props.makeStyles?.()
window.addEventListener('resize', this.updateHeight)
window.addEventListener('resize', this.updateSize)
}

componentDidUpdate(prevProps: ModalProps) {
Expand All @@ -110,11 +111,14 @@ class Modal extends Component<ModalProps, ModalState> {
}

componentWillUnmount() {
window.removeEventListener('resize', this.updateHeight)
window.removeEventListener('resize', this.updateSize)
}

updateHeight = () => {
this.setState({ windowHeight: window.innerHeight })
updateSize = () => {
this.setState({
windowHeight: window.innerHeight,
windowWidth: window.innerWidth
})
}

get defaultFocusElement() {
Expand Down Expand Up @@ -213,13 +217,17 @@ class Modal extends Component<ModalProps, ModalState> {
shouldCloseOnDocumentClick,
shouldReturnFocus,
liveRegion,
size,
constrain,
as,
size,
styles
} = this.props

const isFullScreen = size === 'fullscreen'
const isSmallScreen = this.state.windowWidth < 480 // 30em at 16px base
const borderRadius =
isFullScreen && isSmallScreen ? '0' : (styles?.borderRadius as string) // fullscreen modals on small screens remove border radius so the modal fills edge-to-edge

const dialog = (
<Dialog
{...passthroughProps(props)}
Expand All @@ -234,6 +242,7 @@ class Modal extends Component<ModalProps, ModalState> {
liveRegion={liveRegion}
onDismiss={onDismiss}
css={styles?.modal}
style={{ borderRadius }}
ref={this.contentRef}
// aria-modal="true" see VO bug https://bugs.webkit.org/show_bug.cgi?id=174667
>
Expand All @@ -242,13 +251,7 @@ class Modal extends Component<ModalProps, ModalState> {
)

return (
<Mask
placement={this.maskPlacement}
fullscreen={constrain === 'window'}
themeOverride={
isFullScreen ? { borderRadius: '0em', borderWidth: '0em' } : {}
}
>
<Mask placement={this.maskPlacement} fullscreen={constrain === 'window'}>
{dialog}
</Mask>
)
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-modal/src/Modal/v2/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ type ModalProps = ModalOwnProps &
OtherHTMLAttributes<ModalOwnProps>

type ModalStyle = ComponentStyle<
'modal' | 'constrainContext' | 'joinedHeaderAndBody'
'modal' | 'constrainContext' | 'joinedHeaderAndBody' | 'borderRadius'
>

type ModalState = {
transitioning: boolean
open: boolean
windowHeight: number
windowWidth: number
/**
* The `aria-label` on the Modal's body if it's scrollable.
*/
Expand Down
16 changes: 10 additions & 6 deletions packages/ui-modal/src/Modal/v2/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ const generateStyle = (
},
fullscreen: {
flex: 1,
width: '100%',
height: '100%',
boxShadow: 'none',
border: 'none',
borderRadius: 0
margin: componentTheme.fullScreenMargin,
'@media (max-width: 30em)': {
// small breakpoint = 480px
margin: 0,
boxShadow: 'none',
border: 'none',
borderRadius: 0
}
}
}
const backgroundStyles =
Expand Down Expand Up @@ -123,7 +126,8 @@ const generateStyle = (
overflowY: 'auto',
maxHeight: '20rem'
}
}
},
borderRadius: componentTheme.borderRadius
}
}

Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading