-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebView windows reload on refocus #2
Comments
Potential implementation for solution #2: Use memo to wrap the iframe to prevent re-rendering (https://react.dev/reference/react/memo). |
Note: this also causes an additional bug that prevents a unfocused window from closing when the user clicks on it. The window becomes focused instead of closed. This can easily be fixed by only calling the refocus function if the click doesn't happen on the close button. |
These bugs are caused by each item in the array re-rendering when the order changes (when the focused window changed), this is because the index was used as the key for each item in the array. This can be solved by using a unique id instead of the index. I also recommend using this eslint rule to prevent these issues from reoccurring: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md#prevent-usage-of-array-index-in-keys-reactno-array-index-key |
This issue (unfocused windows not closing) has now been solved: 271338c As for the other issue: Adding a unique key to the array item did not fix it. Edit: further investigation has proven all previous assumption to be false. The webviews do not reload when they change from unfocused to focused. They only reload when the user starts dragging the window around. |
Context: WebView is a new component that is a wrapper for an iframe and is inserted into an application window (as the windowContent property, so it is a child of the window component).
Steps to reproduce
You'll see that the WebView will have reloaded and all your changes will be gone.
Tech analysis
Windows reload due to rerendering when order changes. WebViews lose their state because they use iframes instead of React components.
Assumption: this bug was caused by 80f6e8e
Potential solutions
Pros: No rerendering issues
Cons: lots of work, removes support for viewing web pages as an app
Pros: scalable, keeps support for web pages as app
Cons: effort
The text was updated successfully, but these errors were encountered: