-
Notifications
You must be signed in to change notification settings - Fork 55
fix(mixed): avoid usages of global document
and window
#1970
Conversation
6b6871a
to
6ac9f5b
Compare
Codecov Report
@@ Coverage Diff @@
## master #1970 +/- ##
=========================================
+ Coverage 70.29% 70.3% +0.01%
=========================================
Files 894 894
Lines 7901 7905 +4
Branches 2313 2291 -22
=========================================
+ Hits 5554 5558 +4
Misses 2334 2334
Partials 13 13
Continue to review full report at Codecov.
|
…ps://github.com/stardust-ui/react into fix/document-usage-in-components
}, | ||
"rules": { | ||
"no-undef": "error" | ||
} |
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.
Temporary solution until we will merge #1963.
"files": "src/**/*.{ts,tsx}", | ||
"globals": { | ||
"document": "off", | ||
"window": "off" |
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.
It's reasonable to disable only document
and window
globals as they are context dependent.
@@ -273,7 +273,9 @@ export default class Popup extends AutoControlledComponent<PopupProps, PopupStat | |||
const lastContentRef = getRefs().pop() | |||
const isLastOpenedPopup: boolean = | |||
lastContentRef && lastContentRef.current === this.popupDomElement | |||
const bodyHasFocus: boolean = document.activeElement === document.body | |||
|
|||
const activeDocument = this.props.mountDocument || this.context.target |
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 need to consider remove mountDocument
prop from Popup
at all.
} | ||
this.animationFrameId = window.requestAnimationFrame(() => { | ||
|
||
this.animationFrameId = requestAnimationFrame(() => { |
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.
Discussed with @miroslavstastny, there are no reasons to use it from window
Fixes #1964.
This PR removes remaining usages of
document
andwindow
globals in components. Also forces ESLint to catch such issues.