@@ -370,6 +370,35 @@ const StyledDialog = toggleStyledComponent(
370
370
}
371
371
}
372
372
373
+ /* Used to determine whether there should be a border between the body and footer */
374
+ @keyframes detect-scroll {
375
+ from,
376
+ to {
377
+ --can-scroll: 1;
378
+ }
379
+ }
380
+
381
+ /*
382
+ Add a border between the body and footer if:
383
+ - the dialog has a footer
384
+ - the dialog has a body that can scroll
385
+ - the browser supports the animation-timeline property and its scroll() function
386
+ */
387
+ &:has([data-component='Dialog.Footer']) {
388
+ --can-scroll: 0;
389
+ [data-component='Dialog.Body'] {
390
+ animation: detect-scroll;
391
+ animation-timeline: scroll(self);
392
+
393
+ /* If the browser does not support the animation-timeline property, always show a border */
394
+ border-bottom: var(--borderWidth-default) solid var(--borderColor-default);
395
+
396
+ @supports (animation-timeline: scroll(self)) {
397
+ border-bottom: calc(1px * var(--can-scroll)) solid var(--borderColor-default);
398
+ }
399
+ }
400
+ }
401
+
373
402
${ sx } ;
374
403
` ,
375
404
)
@@ -527,7 +556,13 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
527
556
className = { clsx ( className , enabled && classes . Dialog ) }
528
557
>
529
558
{ header }
530
- < ScrollableRegion aria-labelledby = { dialogLabelId } className = { classes . DialogOverflowWrapper } >
559
+ < ScrollableRegion
560
+ // `data-component` is used for a `:has` selector for `styled-components`.
561
+ // This can be removed when we remove `styled-components`.
562
+ data-component = "Dialog.Body"
563
+ aria-labelledby = { dialogLabelId }
564
+ className = { classes . DialogOverflowWrapper }
565
+ >
531
566
{ body }
532
567
</ ScrollableRegion >
533
568
{ footer }
@@ -623,7 +658,6 @@ const StyledFooter = toggleStyledComponent(
623
658
CSS_MODULES_FEATURE_FLAG ,
624
659
'div' ,
625
660
styled . div < SxProp > `
626
- box-shadow: 0 -1px 0 ${ get ( 'colors.border.default' ) } ;
627
661
padding: ${ get ( 'space.3' ) } ;
628
662
display: flex;
629
663
flex-flow: wrap;
@@ -644,7 +678,16 @@ type StyledFooterProps = React.ComponentProps<'div'> & SxProp
644
678
645
679
const Footer = React . forwardRef < HTMLElement , StyledFooterProps > ( function Footer ( { className, ...rest } , forwardRef ) {
646
680
const enabled = useFeatureFlag ( CSS_MODULES_FEATURE_FLAG )
647
- return < StyledFooter ref = { forwardRef } className = { clsx ( className , enabled && classes . Footer ) } { ...rest } />
681
+ return (
682
+ < StyledFooter
683
+ ref = { forwardRef }
684
+ className = { clsx ( className , enabled && classes . Footer ) }
685
+ // `data-component` is used for a `:has` selector for `styled-components`.
686
+ // This can be removed when we remove `styled-components`.
687
+ data-component = "Dialog.Footer"
688
+ { ...rest }
689
+ />
690
+ )
648
691
} )
649
692
Footer . displayName = 'Dialog.Footer'
650
693
0 commit comments