Skip to content
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

[Bug] With two pybricks code windows open, file menu opens on both #807

Closed
laurensvalk opened this issue Nov 19, 2022 · 4 comments
Closed
Assignees
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application

Comments

@laurensvalk
Copy link
Member

Describe the bug
Open two browser tabs or windows. Click the left hand file icon to open the file bar. Now it opens on both browser windows.

Expected behavior
Button activity constrained to one browser window.

@laurensvalk laurensvalk added the triage Issues that have not been triaged yet label Nov 19, 2022
@dlech
Copy link
Member

dlech commented Nov 19, 2022

The root cause is that we use local storage to persist the state which is shared between all windows. There is a bit more state than just the selected activity tab that is tied to local storage and will affect all open windows.

  • The selected hub for the hub picker control.
  • The use template selection in the new file dialog.
  • The state of the advanced section of the flash Pybricks firmware dialog.
  • The show/hide docs state.

The position of panes that control the size of the docs and the terminal also use local storage, but the control doesn't update when the storage changes so we don't see the change in other windows.

The oneshot for showing the Pybricks tour on first run also uses local storage, but in that case we do want the state shared between windows.

@dlech dlech added bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application and removed triage Issues that have not been triaged yet labels Nov 19, 2022
@dlech
Copy link
Member

dlech commented Nov 19, 2022

Expected behavior
Button activity constrained to one browser window.

What is the expected behavior when you close all windows that are in different states and then open a new window?

@laurensvalk
Copy link
Member Author

I think the current behavior is definitely fine for this release.

I was giving a demo on a small screen when I noticed this, but it is easy enough to just close the file menu again.

@dlech dlech self-assigned this Dec 5, 2022
@dlech dlech added this to To do in Pybricks v3.2 via automation Dec 5, 2022
@dlech dlech moved this from To do to In progress in Pybricks v3.2 Dec 5, 2022
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 6, 2022
The useLocalStorage hook synchronizes state between windows. In the
case of the activities tabs, we don't want this state synchronized,
otherwise changing a tab in one window would change the tab in all
open windows.

Instead, we can use sessionStorage so that the state persists when
refreshing or duplicating a browser tab. Local storage is still used
as the default value so that any new window that is opened will use
the last selected state.

Issue: pybricks/support#807
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 6, 2022
This adds use of sessionStorage for the documentation visibility toggle.
This way, when multiple windows are open, the docs can be controlled
separately in each window. Local storage is still used as the default
value for new windows.

Issue: pybricks/support#807
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 6, 2022
The useLocalStorage hook synchronizes state between windows. In the
case of the activities tabs, we don't want this state synchronized,
otherwise changing a tab in one window would change the tab in all
open windows.

Instead, we can use sessionStorage so that the state persists when
refreshing or duplicating a browser tab. Local storage is still used
as the default value so that any new window that is opened will use
the last selected state.

Issue: pybricks/support#807
dlech added a commit to pybricks/pybricks-code that referenced this issue Dec 6, 2022
This adds use of sessionStorage for the documentation visibility toggle.
This way, when multiple windows are open, the docs can be controlled
separately in each window. Local storage is still used as the default
value for new windows.

Issue: pybricks/support#807
@dlech
Copy link
Member

dlech commented Dec 6, 2022

The cases of the selected activity tab and the documentation show/hide state have been fixed.

@dlech dlech closed this as completed Dec 6, 2022
Pybricks v3.2 automation moved this from In progress to Done Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application
Projects
Pybricks v3.2
  
Done
Development

No branches or pull requests

2 participants