@instructure/ui-modal 11.5.1-snapshot-0 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,7 @@ import type {
49
49
  ModalPropsForPortal,
50
50
  ModalPropsForTransition
51
51
  } from './props'
52
+ import ModalContext from './ModalContext'
52
53
 
53
54
  /**
54
55
  ---
@@ -83,7 +84,8 @@ class Modal extends Component<ModalProps, ModalState> {
83
84
  this.state = {
84
85
  transitioning: false,
85
86
  open: props.open ?? false,
86
- windowHeight: 99999
87
+ windowHeight: 99999,
88
+ bodyScrollAriaLabel: undefined
87
89
  }
88
90
  }
89
91
 
@@ -300,13 +302,21 @@ class Modal extends Component<ModalProps, ModalState> {
300
302
  onClose
301
303
  )}
302
304
  >
303
- {constrain === 'parent' ? (
304
- <span css={this.props.styles?.constrainContext}>
305
- {this.renderDialog(passthroughProps)}
306
- </span>
307
- ) : (
308
- this.renderDialog(passthroughProps)
309
- )}
305
+ <ModalContext.Provider
306
+ value={{
307
+ bodyScrollAriaLabel: this.state.bodyScrollAriaLabel,
308
+ setBodyScrollAriaLabel: (txt: string) =>
309
+ this.setState({ bodyScrollAriaLabel: txt })
310
+ }}
311
+ >
312
+ {constrain === 'parent' ? (
313
+ <span css={this.props.styles?.constrainContext}>
314
+ {this.renderDialog(passthroughProps)}
315
+ </span>
316
+ ) : (
317
+ this.renderDialog(passthroughProps)
318
+ )}
319
+ </ModalContext.Provider>
310
320
  </Transition>
311
321
  </Portal>
312
322
  )
@@ -191,6 +191,10 @@ type ModalState = {
191
191
  transitioning: boolean
192
192
  open: boolean
193
193
  windowHeight: number
194
+ /**
195
+ * The `aria-label` on the Modal's body if it's scrollable.
196
+ */
197
+ bodyScrollAriaLabel?: string
194
198
  }
195
199
  const allowedProps: AllowedPropKeys = [
196
200
  'label',