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

CHANGE isToolshown logic so it hides toolbar if there's only (hidden) canvas #10599

Merged
merged 3 commits into from
Jun 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/ui/src/components/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ const Preview: FunctionComponent<PreviewProps> = (props) => {
baseUrl,
withLoader = true,
} = props;
const { isToolshown } = options;
const { getElements } = api;

const tabs = useTabs(previewId, baseUrl, withLoader, getElements, story);

const isToolshown =
!(viewMode === 'docs' && tabs.filter((t) => !t.hidden).length < 2) && options.isToolshown;
Comment on lines +150 to +151
Copy link
Member Author

Choose a reason for hiding this comment

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

When the viewMode is docs, we only show tabs
When the number of tabs is 1, there's no point in showing them
When we don't show anything, the toolbar should be collapsed

AFAIK this was exactly the issue in #10592

This code makes it so when there's only 1 tab shown in docsmode the toolbar collapses

Copy link
Member

Choose a reason for hiding this comment

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

I didn't repro #10592 but @hipstersmoothie 's issue is that "nothing is rendered". AFAICT this change renders even less than what was there before, so I don't understand how this could solve that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can set up an example repo if neeed

Copy link
Member

Choose a reason for hiding this comment

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

Best is repro in official-storybook

Copy link
Member

Choose a reason for hiding this comment

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

@ndelangen @shilman I've ran this locally and the only issue I see is that on initial load,
the MDX docs-only page that I select on SET_STORIES shows the toolbar like:

image

and after navigate another story with Canvas/Docs tab, and going back, it's not shown:

image

the tabs/reordering seems to work fine with beta.22 :D
now I'd like to know how to set the selectedTab in a similar way as selectedPanel hehe


useEffect(() => {
if (story) {
const { refId, id } = story;
Expand Down