You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The published @fluentui/react package is incorrectly transpiling ES syntax in the module/lib builds. Specifically, this seems to affect use of the new nullish coalescing operator, which the transpiler is giving a lower order of operation than the ternary operator.
I discovered this after troubleshooting why the useWindow context didn't appear to be working, when rendering @fluentui/react components inside a popup window.
Turns out my Friday brain did indeed get the order of operations wrong, and come to the wrong conclusion as to why this is happening.
Nonetheless, the logic in dom.ts needs to be useWindow() ?? (typeof window != 'undefined' ? window : undefined), otherwise the return value of useWindow becomes part of the ternary condition
( I've re-titled the bug to be more appropriate :) )
Jamie0
changed the title
[Bug]: Nullish Coalescing Operator Incorrectly Transpiled In Published Package
[Bug]: Nullish coalescing operator logic in useWindowEx is incorrect
Jul 8, 2024
Library
React / v8 (@fluentui/react)
System Info
Are you reporting Accessibility issue?
None
Reproduction
See lib/utilities/dom.js on NPM
Bug Description
The published @fluentui/react package is incorrectly transpiling ES syntax in the module/
lib
builds. Specifically, this seems to affect use of the new nullish coalescing operator, which the transpiler is giving a lower order of operation than the ternary operator.I discovered this after troubleshooting why the
useWindow
context didn't appear to be working, when rendering@fluentui/react
components inside a popup window.Actual Behavior
useWindowEx is transpiled into (beautified):
The original code is:
which should be executed as:
I suspect adding parantheses in
dom.ts
will fix this particular case.Logs
No response
Requested priority
High
Products/sites affected
No response
Are you willing to submit a PR to fix?
yes
Validations
The text was updated successfully, but these errors were encountered: