Skip to content

Commit

Permalink
test(Modal): fix Modal's rendering in Chromatic viewport to capture a…
Browse files Browse the repository at this point in the history
…ll Modal and not cut it
  • Loading branch information
YossiSaadi committed Dec 10, 2024
1 parent 0fdcf9b commit efb8244
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export const OpenedModalPreview = forwardRef(
const isAfterFirstRender = useAfterFirstRender();
return (
<div
className={cx(styles.preview, getStyle(styles, size))}
className={cx(styles.preview, { [getStyle(styles, size)]: isDocsView })}
ref={ref}
// workaround to prevent modal from autofocusing on page load
// autofocus would work as expected when modal closes and reopens
{...(!isAfterFirstRender.current && isDocsView && { "data-no-autofocus": true })}
>
<Button onClick={onOpenModalClick}>Open Modal</Button>
{isDocsView ? modal : createPortal(modal, document.body)}
{modal}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.preview {
padding-inline-start: 32px;
padding-block-start: 40px;
height: 360px;
height: 100vh;
width: 100%;
container-type: inline-size;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default {
component: Modal,
subcomponents: { ModalBasicLayout, ModalHeader, ModalContent, ModalFooter, ModalFooterWizard, TransitionView },
argTypes: metaSettings.argTypes,
decorators: metaSettings.decorators
decorators: metaSettings.decorators,
parameters: {
layout: "fullscreen"
}
} satisfies Meta<typeof Modal>;

export const Overview: Story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default {
TransitionView
},
argTypes: metaSettings.argTypes,
decorators: metaSettings.decorators
decorators: metaSettings.decorators,
parameters: {
layout: "fullscreen"
}
} satisfies Meta<typeof Modal>;

export const Overview: Story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export default {
TransitionView
},
argTypes: metaSettings.argTypes,
decorators: metaSettings.decorators
decorators: metaSettings.decorators,
parameters: {
layout: "fullscreen"
}
} satisfies Meta<typeof Modal>;

export const Overview: Story = {
Expand Down

0 comments on commit efb8244

Please sign in to comment.