🐛 Bug Report
Modifying HTMLElement.prototype.focus prevents server side rendering.
I'm using Gatsby to build a site which also uses react-spectrum v3. Running the site in development works but once I do a production build an error occurs preventing the site from being built.
🤔 Expected Behavior
I hope to be able to use react-spectrum v3 with a site that is doing server side rendering. 🤞
😯 Current Behavior
Setup the reproduction scenario:
- Clone the reproduction repo.
cd gatsby-rsv3
npm i
Run the client side rendering scenario:
gatsby develop
You'll be able to open localhost:8000 and see that the site is running with a @react-spectrum/button.

Now run the server side scenario:
gatsby clean
gatsby build
This should give you an error message:
963 |
> 964 | let focus = HTMLElement.prototype.focus;
| ^
965 |
966 | HTMLElement.prototype.focus = function () {
967 | $d01f69bb2ab5f70dfd0005370a2a2cbc$var$hasEventBeforeFocus = true;
WebpackError: ReferenceError: HTMLElement is not defined
- module.js:964
node_modules/@react-aria/interactions/dist/module.js:964:1
- module.js:1018
node_modules/@react-aria/interactions/dist/module.js:1018:1
- module.js:392
node_modules/@react-aria/focus/dist/module.js:392:22
- module.js:427
node_modules/@react-aria/focus/dist/module.js:427:4
💁 Possible Solution
If I find something I'll come back here and update.
🔦 Context
It's keeping us from switching over from react-spectrum v2 on our internal doc site: https://docs.corp.adobe.com/
💻 Code Sample
Sample repo that provides the smallest reproduction scenario I could come up with is at:
https://github.com/macdonst/gatsby-rsv3
🌍 Your Environment
| Software |
Version(s) |
| react-spectrum |
"@react-spectrum/button": "^3.0.0", "@react-spectrum/provider": "^3.0.0", "@react-spectrum/theme-default": "^3.0.0" |
| Browser |
n/a |
| Operating System |
MacOS 10.15.5 |
🧢 Your Team
Adobe I/O
🕷 Tracking Issue
n/a
🐛 Bug Report
Modifying
HTMLElement.prototype.focusprevents server side rendering.I'm using Gatsby to build a site which also uses react-spectrum v3. Running the site in development works but once I do a production build an error occurs preventing the site from being built.
🤔 Expected Behavior
I hope to be able to use react-spectrum v3 with a site that is doing server side rendering. 🤞
😯 Current Behavior
Setup the reproduction scenario:
cd gatsby-rsv3npm iRun the client side rendering scenario:
gatsby developYou'll be able to open localhost:8000 and see that the site is running with a
@react-spectrum/button.Now run the server side scenario:
gatsby cleangatsby buildThis should give you an error message:
💁 Possible Solution
If I find something I'll come back here and update.
🔦 Context
It's keeping us from switching over from react-spectrum v2 on our internal doc site: https://docs.corp.adobe.com/
💻 Code Sample
Sample repo that provides the smallest reproduction scenario I could come up with is at:
https://github.com/macdonst/gatsby-rsv3
🌍 Your Environment
🧢 Your Team
Adobe I/O
🕷 Tracking Issue
n/a