-
Notifications
You must be signed in to change notification settings - Fork 110
Fullscreen modal margin #2567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fullscreen modal margin #2567
Changes from all commits
e5880af
fe073f1
667b571
7d3d6f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,7 @@ class Modal extends Component<ModalProps, ModalState> { | |
| transitioning: false, | ||
| open: props.open ?? false, | ||
| windowHeight: 99999, | ||
| windowWidth: 99999, | ||
| bodyScrollAriaLabel: undefined | ||
| } | ||
| } | ||
|
|
@@ -99,7 +100,7 @@ class Modal extends Component<ModalProps, ModalState> { | |
|
|
||
| componentDidMount() { | ||
| this.props.makeStyles?.() | ||
| window.addEventListener('resize', this.updateHeight) | ||
| window.addEventListener('resize', this.updateSize) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might need some conditionals here, |
||
| } | ||
|
|
||
| componentDidUpdate(prevProps: ModalProps) { | ||
|
|
@@ -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() { | ||
|
|
@@ -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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit off, but in the previous styling enginer breakpoints were defined at theme level. This might be better for us too, so we dont have components changing visuals lots of times when resizing a window. |
||
| 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)} | ||
|
|
@@ -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 | ||
| > | ||
|
|
@@ -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> | ||
| ) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not allow to set users CSS for our components. It opens up way too many possibilities leading to inconsistent design and bugs for users during internal styles changes.
We could pass have a
borderRadiusprop if needed (that defaults toinherit)