Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit d954616

Browse files
authored
chore(Popup|MenuButton): remove mountDocument prop (#2286)
* chore(Popup|MenuButton): remove `mountDocument` prop * add changelog entry
1 parent 99ad7d4 commit d954616

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2626
- Add logic for mounting/removing elements when they are shown/hidden using the `Animation` component; `Animation` component is not rendering element anymore, just applying classes to it's children @mnajdova ([#2115](https://github.com/microsoft/fluent-ui-react/pull/2115))
2727
- Restricted prop set in the `Button`, `Avatar`, `Box` and `Image` styles; changed `avatarBorderWidth` and `statusBorderWidth` avatar variables types from number to string and updated styles in Teams theme @mnajdova ([#2238](https://github.com/microsoft/fluent-ui-react/pull/2238))
2828
- Restricted prop set in the `List` & `ListItem` @layershifter ([#2238](https://github.com/microsoft/fluent-ui-react/pull/2238))
29+
- Remove `mountDocument` prop in `Popup` & `MenuButton` components @layershifter ([#2286](https://github.com/microsoft/fluent-ui-react/pull/2286))
2930

3031
### Fixes
3132
- Fix event listener leak in `FocusZone` @miroslavstastny ([#2227](https://github.com/microsoft/fluent-ui-react/pull/2227))

packages/react/src/components/MenuButton/MenuButton.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ export interface MenuButtonProps extends StyledComponentProps<MenuButtonProps>,
3939
/** Initial value for 'open'. */
4040
defaultOpen?: boolean
4141

42-
/** Existing document the popup should add listeners. */
43-
mountDocument?: Document
44-
4542
/** Existing element the popup should be bound to. */
4643
mountNode?: HTMLElement
4744

@@ -118,7 +115,6 @@ export default class MenuButton extends AutoControlledComponent<MenuButtonProps,
118115
}),
119116
align: PropTypes.oneOf(ALIGNMENTS),
120117
defaultOpen: PropTypes.bool,
121-
mountDocument: PropTypes.object,
122118
mountNode: customPropTypes.domNode,
123119
mouseLeaveDelay: PropTypes.number,
124120
offset: PropTypes.string,
@@ -214,7 +210,6 @@ export default class MenuButton extends AutoControlledComponent<MenuButtonProps,
214210
align,
215211
className,
216212
defaultOpen,
217-
mountDocument,
218213
mountNode,
219214
mouseLeaveDelay,
220215
offset,
@@ -236,7 +231,6 @@ export default class MenuButton extends AutoControlledComponent<MenuButtonProps,
236231
align,
237232
className,
238233
defaultOpen,
239-
mountDocument,
240234
mountNode,
241235
mouseLeaveDelay,
242236
offset,

packages/react/src/components/Popup/Popup.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ export interface PopupProps
7070
/** Whether the Popup should be rendered inline with the trigger or in the body. */
7171
inline?: boolean
7272

73-
/** Existing document the popup should add listeners. */
74-
mountDocument?: Document
75-
7673
/** Existing element the popup should be bound to. */
7774
mountNode?: HTMLElement
7875

@@ -151,7 +148,6 @@ export default class Popup extends AutoControlledComponent<PopupProps, PopupStat
151148
align: PropTypes.oneOf(ALIGNMENTS),
152149
defaultOpen: PropTypes.bool,
153150
inline: PropTypes.bool,
154-
mountDocument: PropTypes.object,
155151
mountNode: customPropTypes.domNode,
156152
mouseLeaveDelay: PropTypes.number,
157153
offset: PropTypes.string,
@@ -288,7 +284,7 @@ export default class Popup extends AutoControlledComponent<PopupProps, PopupStat
288284
const isLastOpenedPopup: boolean =
289285
lastContentRef && lastContentRef.current === this.popupDomElement
290286

291-
const activeDocument = this.props.mountDocument || this.context.target
287+
const activeDocument: HTMLDocument = this.context.target
292288
const bodyHasFocus: boolean = activeDocument.activeElement === activeDocument.body
293289

294290
if (keyCode === keyboardKey.Escape && bodyHasFocus && isLastOpenedPopup) {
@@ -499,14 +495,13 @@ export default class Popup extends AutoControlledComponent<PopupProps, PopupStat
499495
content: propsContent,
500496
renderContent,
501497
contentRef,
502-
mountDocument,
503498
pointing,
504499
trapFocus,
505500
autoFocus,
506501
} = this.props
507502

508503
const content = renderContent ? renderContent(scheduleUpdate) : propsContent
509-
const targetRef = toRefObject(mountDocument || this.context.target)
504+
const targetRef = toRefObject(this.context.target)
510505

511506
const popupContent = Popup.Content.create(content || {}, {
512507
defaultProps: () => ({
@@ -621,9 +616,7 @@ export default class Popup extends AutoControlledComponent<PopupProps, PopupStat
621616
* Can be either trigger DOM element itself or the element inside it.
622617
*/
623618
updateTriggerFocusableDomElement() {
624-
const { mountDocument } = this.props
625-
626-
const activeDocument = mountDocument || this.context.target
619+
const activeDocument: HTMLDocument = this.context.target
627620
const activeElement = activeDocument.activeElement
628621

629622
this.triggerFocusableDomElement =

0 commit comments

Comments
 (0)