Skip to content

Commit be0e26c

Browse files
committed
fix(Dialog): Make footer scrollable on very short viewports
1 parent c065ec5 commit be0e26c

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

.changeset/little-papayas-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Make Dialog footer scrollable on very short viewports

packages/react/src/Dialog/Dialog.module.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,15 @@
244244
z-index: 1;
245245
display: flex;
246246
padding: var(--base-size-16);
247-
/* stylelint-disable-next-line primer/box-shadow */
247+
/* stylelint-disable-next-line primer/box-shadow*/
248248
box-shadow: 0 -1px 0 var(--borderColor-default);
249-
flex-flow: wrap;
250-
justify-content: flex-end;
249+
flex-direction: row-reverse;
250+
flex-wrap: wrap-reverse;
251+
252+
@media (max-height: 256px) {
253+
flex-wrap: nowrap;
254+
overflow-x: scroll;
255+
}
251256
gap: var(--base-size-8);
252257
flex-shrink: 0;
253258
}

packages/react/src/Dialog/Dialog.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,16 @@ const StyledFooter = toggleStyledComponent(
626626
box-shadow: 0 -1px 0 ${get('colors.border.default')};
627627
padding: ${get('space.3')};
628628
display: flex;
629-
flex-flow: wrap;
630-
justify-content: flex-end;
629+
flex-direction: row-reverse;
630+
flex-wrap: wrap-reverse;
631631
gap: ${get('space.2')};
632632
z-index: 1;
633633
flex-shrink: 0;
634634
635+
@media (max-height: 256px) {
636+
flex-wrap: nowrap;
637+
overflow-x: scroll;
638+
}
635639
${sx};
636640
`,
637641
)
@@ -658,20 +662,22 @@ const Buttons: React.FC<React.PropsWithChildren<{buttons: DialogButtonProps[]}>>
658662

659663
return (
660664
<>
661-
{buttons.map((dialogButtonProps, index) => {
662-
const {content, buttonType = 'default', autoFocus = false, ...buttonProps} = dialogButtonProps
663-
return (
664-
<Button
665-
key={index}
666-
{...buttonProps}
667-
// 'normal' value is equivalent to 'default', this is used for backwards compatibility
668-
variant={buttonType === 'normal' ? 'default' : buttonType}
669-
ref={autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null}
670-
>
671-
{content}
672-
</Button>
673-
)
674-
})}
665+
{buttons
666+
.map((dialogButtonProps, index) => {
667+
const {content, buttonType = 'default', autoFocus = false, ...buttonProps} = dialogButtonProps
668+
return (
669+
<Button
670+
key={index}
671+
{...buttonProps}
672+
// 'normal' value is equivalent to 'default', this is used for backwards compatibility
673+
variant={buttonType === 'normal' ? 'default' : buttonType}
674+
ref={autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null}
675+
>
676+
{content}
677+
</Button>
678+
)
679+
})
680+
.reverse()}
675681
</>
676682
)
677683
}

0 commit comments

Comments
 (0)