Skip to content

Commit

Permalink
Text Selection in Safari: Try new fix for recent version (#44148)
Browse files Browse the repository at this point in the history
* Text Selection in Safari: Try new fix for recent version

* Fix issue.

* Better fix.
  • Loading branch information
jasmussen authored Sep 16, 2022
1 parent c437a0e commit a7b0673
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
.block-editor-block-list__layout {
position: relative;

// Hide selections on this element, otherwise Safari will include it stacked
// under your actual selection.
&::selection {
background: transparent;
}

// The primary indicator of selection in text is the native selection marker.
// When selecting multiple blocks, we provide an additional selection indicator.
.block-editor-block-list__block.is-multi-selected:not(.is-partially-selected),
Expand Down Expand Up @@ -51,6 +57,11 @@
}
}

// Hide the selection indicator on .block-editor-block-list__layout, else Safari will show it stacked.
.has-multi-selection &::selection {
background: transparent;
}

.block-editor-block-list__block.is-highlighted::after {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
outline: $border-width solid transparent;
Expand Down Expand Up @@ -128,14 +139,22 @@
// Re-enable text-selection on editable blocks.
user-select: text;

// Hide the select style pseudo element as it interferes with the style.
// Hide the select style pseudo element as otherwise it gets shwon as "selected" in Safari.
&.is-partially-selected::after {
height: 0;
// By positioning this pseudo element outside the boundaries of the parent block,
// when partially selected it hides the pseudo element selection in Safari.
top: -0.5px;
right: -0.5px;
bottom: -0.5px;
left: -0.5px;
}

&.is-highlighted::after,
&.is-highlighted ~ .is-multi-selected::after {
height: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
}

// Break long strings of text without spaces so they don't overflow the block.
Expand Down

0 comments on commit a7b0673

Please sign in to comment.