@instructure/ui-modal 10.29.0 → 10.30.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.
@@ -50,6 +50,7 @@ import type {
50
50
  ModalPropsForPortal,
51
51
  ModalPropsForTransition
52
52
  } from './props'
53
+ import ModalContext from './ModalContext'
53
54
 
54
55
  /**
55
56
  ---
@@ -86,7 +87,8 @@ class Modal extends Component<ModalProps, ModalState> {
86
87
  this.state = {
87
88
  transitioning: false,
88
89
  open: props.open ?? false,
89
- windowHeight: 99999
90
+ windowHeight: 99999,
91
+ bodyScrollAriaLabel: undefined
90
92
  }
91
93
  }
92
94
 
@@ -302,13 +304,21 @@ class Modal extends Component<ModalProps, ModalState> {
302
304
  onClose
303
305
  )}
304
306
  >
305
- {constrain === 'parent' ? (
306
- <span css={this.props.styles?.constrainContext}>
307
- {this.renderDialog(passthroughProps)}
308
- </span>
309
- ) : (
310
- this.renderDialog(passthroughProps)
311
- )}
307
+ <ModalContext.Provider
308
+ value={{
309
+ bodyScrollAriaLabel: this.state.bodyScrollAriaLabel,
310
+ setBodyScrollAriaLabel: (txt: string) =>
311
+ this.setState({ bodyScrollAriaLabel: txt })
312
+ }}
313
+ >
314
+ {constrain === 'parent' ? (
315
+ <span css={this.props.styles?.constrainContext}>
316
+ {this.renderDialog(passthroughProps)}
317
+ </span>
318
+ ) : (
319
+ this.renderDialog(passthroughProps)
320
+ )}
321
+ </ModalContext.Provider>
312
322
  </Transition>
313
323
  </Portal>
314
324
  )
@@ -197,6 +197,10 @@ type ModalState = {
197
197
  transitioning: boolean
198
198
  open: boolean
199
199
  windowHeight: number
200
+ /**
201
+ * The `aria-label` on the Modal's body if it's scrollable.
202
+ */
203
+ bodyScrollAriaLabel?: string
200
204
  }
201
205
 
202
206
  const propTypes: PropValidators<PropKeys> = {