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

UI: Fullscreen toggle does not work when all panels are collapsed #11810

Conversation

Tomastomaslol
Copy link
Member

@Tomastomaslol Tomastomaslol commented Aug 5, 2020

Issue: #11782

What I did

  • When exiting isFullScreen and navigation is not show set showNav to true
  • When togglePanel is invoked and the panel should be hidden and navigation is hidden. Set isFullScreen to true
  • When toggleNav is invoked and the navigation should be hidden and the panel is hidden. Set isFullScreen to true

How to test

The expected behaviour is described here: #11782 (comment)

Scenario 1

  • Hide Panel and Nav
  • Should Enter fullscreen mode automatically
  • Exit fullscreen mode
  • Navigation should be shown

Kapture 2020-08-17 at 9 42 09

Scenario 2

  • Hide Nav
  • Enter fullscreen mode
  • Exit fullscreen mode
  • Navigation and panel should be shown

Kapture 2020-08-17 at 9 50 42

Scenario 3

  • Hide Panel
  • Enter fullscreen mode
  • Exit fullscreen mode
  • Navigation should be shown

3

Scenario 4

  • Enter fullscreen mode
  • Exit fullscreen mode
  • Navigation and panel should be shown

4

@yannbf
Copy link
Member

yannbf commented Aug 20, 2020

Awesome work @Tomastomaslol !!!

I'm just wondering about scenario 3:

Hide Panel
Enter fullscreen mode
Exit fullscreen mode
Navigation should be shown

If we check @domyen's explanation:

When you press the close button in full screen mode, it should open the sidebar. If the addon panel was previous open it should take you back to it's previous state. If the previous state of the sidebar or addon panel can't be determined, reset the manager UI.

So in this case, at least from what I read, when exiting full screen mode, having the panel being hidden previously, it should go back to the previous state, which is panel open, navigation hidden. Please correct me if I'm wrong @domyen.

Also, there was also a nice suggestion to give a hint of the shortcuts in the buttons:
image
"Go full screen [F]"

image
"Change addon orientation [D]
"Hide addons [A]"

Would you be so kind to add that as well?

@Tomastomaslol
Copy link
Member Author

Hi @yannbf. I appreciate you taking the time to look at my pull request. I updated the titles I missed in my previous commit.

Here is how I interpreter the instructions:

When you press the close button in full screen mode, it should open the sidebar.

So exiting full-screen mode should always open the sidebar.

If the addon panel was previous open it should take you back to it's previous state.

Does this mean the state previous to when the full-screen mode was toggled? If so I believe the my suggested implementation is correct.

But if this means its own previous state if the state has changed, I need to give this another go.

Please let me know if I misunderstood anything or if you would like to change the suggested implementation.

>
<Icons icon={panelPosition === 'bottom' ? 'bottombar' : 'sidebaralt'} />
</DesktopOnlyIconButton>
<DesktopOnlyIconButton
key="visibility"
onClick={actions.toggleVisibility}
title="Hide addons"
title="Hide addons [A]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are not hard coded, but rather user configurable!

Copy link
Member

@yannbf yannbf Aug 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume to get them it's kinda like this?

import { Consumer } from '@storybook/api';

const Component = () => (
  <Consumer>
    {({ api }) => {
      const shortcuts = api.getShortcutKeys();
      return (
        <>
          <ComponentForFullScreen title={`Toggle fullscreen [${shortcuts.fullScreen}]`} />;
          <ComponentForAddonOrientation
            title={`Change addon orientation [${shortcuts.panelPosition}]`}
          />
          ;
          <ComponentForHidingAddons title={`Hide addons [${shortcuts.togglePanel}]`} />;
        </>
      );
    }}
  </Consumer>
);

Or is there another way to get them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I fixed this issue in my latest commit please let me what you think of my proposed solution.

Copy link
Member

@ndelangen ndelangen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hotkeys are configurable

@Tomastomaslol Tomastomaslol force-pushed the 11782_fullscreen_toggle_does_not_work_when_all_panels_are_collapsed branch from 164d583 to db28605 Compare August 29, 2020 02:39
@yannbf
Copy link
Member

yannbf commented Aug 29, 2020

It all seems good to me!
@domyen could you please double check this PR, especially this comment? Thanks!

@shilman
Copy link
Member

shilman commented Sep 8, 2020

@Tomastomaslol it looks like CI is failing. can you take a look?

Error: Evaluation failed: TypeError: Cannot read property 'getShortcutKeys' of undefined
    at Object.PanelMapper [as current] (https://5a375b97f4b14f0020b0cda3-chgwvaljgf.chromatic.com/main.2dee079d08dfc61f7a62.bundle.js:1:462099)
    at ManagerConsumer (webpack://storybook_docs_dll//tmp/storybook/lib/api/dist/index.js?:624:23)

@domyen
Copy link
Member

domyen commented Sep 8, 2020 via email

@domyen
Copy link
Member

domyen commented Sep 9, 2020

@Tomastomaslol thanks so much for this PR! 🙇‍♂️

The gifs are super helpful.

If the addon panel was previous open it should take you back to it's previous state.

Does this mean the state previous to when the full-screen mode was toggled? If so I believe the my suggested implementation is correct.

✅ I think you got it. The deploy previews are down so it's tough to verify the behavior.

✅Example A:

  1. Rest state is the sidebar and addon panel are shown
  2. User goes full screen, sidebar and addon panel are hidden
  3. User exits full screen, sidebar and addon panel are shown

✅Example B:

  1. Rest state is the sidebar is shown and addon panel is hidden
  2. User goes full screen, sidebar is hidden and addon panel continues to be hidden
  3. User exits full screen, sidebar is shown and addon panel continues to be hidden

Also, thank you @yannbf for guiding this issue and PR home 🙏

@Tomastomaslol
Copy link
Member Author

Tomastomaslol commented Sep 9, 2020

@shilman Thanks for pointing out the failing tests. In the future, I will pay more attention to checks and its outcomes to make sure it hasn't flagged any issues in my PR.

While fixing the tests I realised there were better ways to structure my code so I did some refactoring. There should be no change to functionality.

@domyen I appreciate you taking time look at my code and helping me verify the behaviour!

And thanks for all the help @yannbf. I had a lot of fun working on this! 🙂

@yannbf yannbf added the bug label Sep 15, 2020
@stale
Copy link

stale bot commented Oct 12, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Oct 12, 2020
@yannbf yannbf removed the inactive label Oct 12, 2020
@shilman shilman added the ui label Oct 12, 2020
@domyen
Copy link
Member

domyen commented Oct 13, 2020

This is ready to go from my end pending CI passing 👍

@shilman shilman added this to the 6.1 core milestone Oct 15, 2020
@shilman shilman changed the title Fullscreen toggle does not work when all panels are collapse UI: Fullscreen toggle does not work when all panels are collapsed Oct 15, 2020
@shilman shilman merged commit a40a7db into storybookjs:next Oct 15, 2020
@Tomastomaslol Tomastomaslol deleted the 11782_fullscreen_toggle_does_not_work_when_all_panels_are_collapsed branch October 15, 2020 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants