-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text selection: show CSS hack to Safari only. #57300
Conversation
Size Change: +56 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
// Hide selections on this element, otherwise Safari will include it stacked | ||
// under your actual selection. | ||
&::selection { | ||
background: transparent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-enabling this doesn't work in Chrome?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry can you clarify?
What does text selection look like on the front-end in Safari? Also, do we know what is causing this weird selection? |
Looks like this: However that's still not accurate to any of the selections inside the editor.
Yes, there's more detail in #44148, specifically here, but the gist is that every single element that exists is highlighted in Safari, including all the extra cruft we have in the editor, such as pseudo elements, added div wrappers and containers, every single fragment, etc. So unless we could have identical markup in editor and frontend, there will always be a difference between editor and frontend selection style in Safari. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as advertised. I dont think the experience in Safari without the hack is bad, but since we've gone to the effort of fixing it we might as well ship it!
I'll let this sit for a bit more to collect feedback, but others should feel free to press the green button here as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this out and it looks like it's working well for me:
- I can replicate the issues in Chrome Canary and Safari without this PR ✅
- Chrome base behaviour is consistent between trunk and this PR ✅
- Safari works well with this PR ✅
I tested using TT4 with multiple paragraph blocks and with columns with nested images and paragraph blocks.
I just cherry-picked this PR to the 6.4/latest-fixes branch to get it included in the next release: daa20d4 |
Package Update includes fixes for: - Image Block: Enable image block to be selected correctly when clicked. - Reduce specificity of default Cover text color styles. - Image Block: Fix deprecation when width/height attribute is number. - Text selection: show CSS hack to Safari only. - SlotFill: Allow contextual SlotFillProviders. See: #5696 See: WordPress/gutenberg@bd6767b See: WordPress/gutenberg#56043 See: WordPress/gutenberg#56411 See: WordPress/gutenberg#57063 See: WordPress/gutenberg#57300 See: WordPress/gutenberg#56779 Props mikachan, wildworks, alexstine, poena, isabel_brison, andrewserong, czapla, andraganescu, joen, ellatrix, youknowriad, ntsekouras. Fixes #59943, #59943. git-svn-id: https://develop.svn.wordpress.org/trunk@57258 602fd350-edb4-49c9-b593-d223f7449a82
Package Update includes fixes for: - Image Block: Enable image block to be selected correctly when clicked. - Reduce specificity of default Cover text color styles. - Image Block: Fix deprecation when width/height attribute is number. - Text selection: show CSS hack to Safari only. - SlotFill: Allow contextual SlotFillProviders. See: WordPress/wordpress-develop#5696 See: WordPress/gutenberg@bd6767b See: WordPress/gutenberg#56043 See: WordPress/gutenberg#56411 See: WordPress/gutenberg#57063 See: WordPress/gutenberg#57300 See: WordPress/gutenberg#56779 Props mikachan, wildworks, alexstine, poena, isabel_brison, andrewserong, czapla, andraganescu, joen, ellatrix, youknowriad, ntsekouras. Fixes #59943, #59943. Built from https://develop.svn.wordpress.org/trunk@57258 git-svn-id: http://core.svn.wordpress.org/trunk@56764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Package Update includes fixes for: - Image Block: Enable image block to be selected correctly when clicked. - Reduce specificity of default Cover text color styles. - Image Block: Fix deprecation when width/height attribute is number. - Text selection: show CSS hack to Safari only. - SlotFill: Allow contextual SlotFillProviders. See: WordPress/wordpress-develop#5696 See: WordPress/gutenberg@bd6767b See: WordPress/gutenberg#56043 See: WordPress/gutenberg#56411 See: WordPress/gutenberg#57063 See: WordPress/gutenberg#57300 See: WordPress/gutenberg#56779 Props mikachan, wildworks, alexstine, poena, isabel_brison, andrewserong, czapla, andraganescu, joen, ellatrix, youknowriad, ntsekouras. Fixes #59943, #59943. Built from https://develop.svn.wordpress.org/trunk@57258 git-svn-id: https://core.svn.wordpress.org/trunk@56764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What?
Alternative to #57298, fixes #56408.
There's a CSS hack that exists for making the selection style in Safari more precise. This hack has side effects in Chrome Canary, and this PR fixes that by showing the Safari hack to Safari only.
Hacks are bad, but this hack, should it fail, it would fail only in Safari, and the result would be the same as removing the hack, so the selection would still show, it would just show as the "before" image, as shown below.
Chrome base, before:
Chrome Canary before:
Safari before:
Safari with the hack plainly removed (without the hack that makes the selection precise, note how the selection goes edge to edge between blocks):
After this PR, Chrome base:
After, Chrome Canary:
After, Safari with debugging colors to test the hack in this PR:
After, Safari with the transparent color:
Testing Instructions
Please test first, selecting across multiple paragraphs, then multiple non-text paragraphs, be sure to also test nested blocks.
Test in Chrome, Chrome Canary, Safari. The selection style should look the same across all three.