Skip to content

Commit

Permalink
fix(Storybook): Resolve storybook docs styling in Firefox
Browse files Browse the repository at this point in the history
Storybook obscures components that have hidden elements (think ContextMenu or DatePicker) when viewed with the Firefox browser.

This made the docs section almost unusable in Firefox. The only solution at this time appears to be overiding some Storybook styles.

storybookjs/storybook#16714
storybookjs/storybook#8928

Included a `ContextMenu` cypress test to help catch the issue with Storybook version bumps.
  • Loading branch information
m7kvqbe1 committed Nov 17, 2021
1 parent 37ca04f commit 8894ba3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
24 changes: 22 additions & 2 deletions packages/react-component-library/.storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
rel="stylesheet"
/>
<style type="text/css">
.sbdocs-h2:first-of-type { margin-bottom: 40px; }
.rn-sidebar--storybook { position: unset !important; max-height: 30rem; }
/* https://github.com/storybookjs/storybook/issues/8928 */
#docs-root .sbdocs-h2:first-of-type {
margin-bottom: 40px;
}

#docs-root .docs-story {
overflow: visible;
}

#docs-root .docs-story > div:last-child {
bottom: 10px;
}

#docs-root .docs-story > div:first-child > div:first-child {
transform: none;
height: auto;
}

.rn-sidebar--storybook {
position: unset !important;
max-height: 30rem;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
target: '[data-testid="storybook-context-menu-target"]',
menu: '[data-testid="context-menu"]',
}
4 changes: 3 additions & 1 deletion packages/react-component-library/cypress/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import datePicker from './DatePicker'
import contextMenu from './ContextMenu'
import timeline from './timeline'
import form from './form'

export default {
datePicker,
contextMenu,
timeline,
form
form,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, cy, it, before } from 'local-cypress'

import selectors from '../../selectors'

// https://github.com/storybookjs/storybook/issues/8928

describe('ContextMenu', () => {
describe('Storybook: Docs Mode', () => {
describe('the user opens the menu', () => {
before(() => {
cy.visit('/iframe.html?id=context-menu--default&viewMode=docs')

cy.get(selectors.contextMenu.target).eq(0).rightclick()
})

it('should show the Context Menu unobscured', () => {
cy.get(selectors.contextMenu.menu)
.contains('This is too much text')
.should('be.visible')
})
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ClickArea = React.forwardRef(({ children, ...rest }: any, ref: any) => (
padding: '1rem',
backgroundColor: '#c9c9c9',
}}
data-testid="storybook-context-menu-target"
>
{children}
</div>
Expand Down

0 comments on commit 8894ba3

Please sign in to comment.