Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/ten-candles-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': patch
---

Fix for List objects with columns in Safari that include visually hidden elements or elements with content divided between columns
51 changes: 30 additions & 21 deletions src/objects/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,29 @@
@use '../../mixins/fluid';
@use '../../mixins/media-query';

/**
* Override browser defaults. Note that this means it's very important to
* include `[role="list"]` to prevent disruption of list navigation in Safari
* VoiceOver.
*
* @see https://www.scottohara.me/blog/2019/01/12/lists-and-safari.html
*/
/// Override browser defaults. Note that this means it's very important to
/// include `[role="list"]` to prevent disruption of list navigation in Safari
/// VoiceOver, unless the content itself makes its nature obvious.
///
/// @link https://www.scottohara.me/blog/2019/01/12/lists-and-safari.html

.o-list {
list-style: none;
padding-inline-start: 0;
}

/**
* Modifier: Inline
*
* By default, this uses negative margins on the sides to account for extra
* margin between child elements. This allows child elements to reach the edges
* of their parent while maintaining consistent gaps between.
*
* This would be a _lot_ more elegant if it used the Flexbox-compatible `gap`
* property. But unfortunately there is no way to test for that without false
* positives as of this writing.
*
* @see https://medium.com/@schofeld/mind-the-flex-gap-c9cd1b4b35d8
* @see https://github.com/w3c/csswg-drafts/issues/3559
*/
/// Modifier: Inline
///
/// By default, this uses negative margins on the sides to account for extra
/// margin between child elements. This allows child elements to reach the edges
/// of their parent while maintaining consistent gaps between.
///
/// This would be a _lot_ more elegant if it used the Flexbox-compatible `gap`
/// property. But unfortunately there is no way to test for that without false
/// positives as of this writing.
///
/// @link https://medium.com/@schofeld/mind-the-flex-gap-c9cd1b4b35d8
/// @link https://github.com/w3c/csswg-drafts/issues/3559

.o-list--inline {
display: flex;
Expand All @@ -52,6 +48,19 @@
breakpoint.$xl
);
columns: #{$i};
position: relative;

/// Safari has some odd bugs related to CSS multi-column. Specifically:
///
/// 1. Without this, the top of an item may appear in one column with the
/// bottom half in the following column.
/// 2. Without this, `position: absolute` elements will impact the overall
/// window scroll height, even if they're invisible (as with our
/// `u-hidden-visually` utility).
> * {
break-inside: avoid; // 1
position: relative; // 2
}
}
}
}
6 changes: 5 additions & 1 deletion src/objects/overview/demo/advanced.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
} %}
{% block content %}
{% for topic in topics %}
<li class="u-space-block-end-0">
{#
We must use padding between items because Safari likes to carry
margin across columns.
#}
<li class="u-pad-block-end-0">
{% include '@cloudfour/components/dot-leader/dot-leader.twig' with {
label: topic.title,
count: topic.count,
Expand Down
6 changes: 5 additions & 1 deletion src/prototypes/article-listing/example/example.twig
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@
} %}
{% block content %}
{% for topic in topics %}
<li class="u-space-block-end-0">
{#
We must use padding between items because Safari likes to
carry margin across columns.
#}
<li class="u-pad-block-end-0">
{% include '@cloudfour/components/dot-leader/dot-leader.twig' with {
label: topic.title,
count: topic.count,
Expand Down