-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Ensure editor body fits all notes #72811
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
Ensure editor body fits all notes #72811
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +289 B (+0.01%) Total Size: 2.38 MB
ℹ️ View Unchanged
|
|
|
||
| // Ensure the editor has enough height to scroll to all notes. | ||
| // last note top plus height to determine the bottom position. | ||
| const iframe = document.querySelector( |
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.
maybe this should us getEditorRegion from packages/block-editor/src/utils/get-editor-region.js?
|
Flaky tests detected in 759ac66. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18967676712
|
|
This approach more closely mimics Google Docs where lengthy comments scroll the doc content above the fold. I had originally thought that wouldn't look/work well in the block editor but that After video seems pretty fine to me. Two questions @adamsilverstein is what happens if you have a drawer active below the post content (e.g. Yoast) as well as what happens if you scroll down past the post content and then click on a comment (will it scroll you back up to where the related block begins such that its back in frame or will the block and post content area still be above the fold)? |
Exactly!
the code only sets the minimum height (min-height) for the editor frame body, so if an active drawer needs more space that will not be affected by this at all.
I'm not changing that behavior - when you click on a comment it will scroll to the related block and pin alongside it. threads above will be pushed away above. New with this PR, to reach the bottom, you would just scroll down (in trunk, you can't reach the bottom, its cut off). This part might not be working perfectly in the PR yet, I'm going to work on that more. |
I was able to correct the glitches and simplify the calculation in e616b5e. Previously I wasn't taking into account the editor scroll position in the calculations. This resolves all the edge cases, give it a test in Playground. |
|
Looking at the codebase, I think we could expose a private API from the editor to set the min-height, this would make the code more reactive. What do you think? |
|
Oops, those last commits were off, re-working shortly. |
|
Ok, the reactive implementation is restored. |
jasmussen
left a comment
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.
Despite my prior skepticism to extending the canvas, this is clearly the best solution yet:
Apologies for the detour. This works very well, kudos, nice work.
I do think there's a point in the future where we elide comments with "Read more" links and collapse long threads, but that's not today, and with this PR the bases are covered.
Approving from an experience perspective, it could use a code gut check by the other folks pinged.
|
Pushed some refactorings:
|
Thanks for the refactoring @Mamaduka - nice improvements! I tested this again and everything works as expected. I was only able to trigger the wrong height in a few edge cases I couldn't reproduced and in every case all notes were fully visible (slightly too much space was added). |
|
I briefly tested with playground and found that when adding notes to a block before or after one with a long note there was some behavior that surprised me. The worst was adding a note to a block after one with the long note, where the note was only accessible in the non-floating sidebar. Here’s a recording: 72811-add-note-around-long-note.mp4This seems like it should work quite well though. Good work! |
|
@stokesman Thanks for testing! I was not able to reproduce the behavior you saw and I'm suspicious the playground build is out of date. Here is my screen recording for the record, maybe I missed a step: add-note.mp4 |
|
There was a conflict while trying to cherry-pick the commit to the wp/6.9 branch. Please resolve the conflict manually and create a PR to the wp/6.9 branch. PRs to wp/6.9 are similar to PRs to trunk, but you should base your PR on the wp/6.9 branch instead of trunk. |
|
Backported in #72886 |

Fixes #72440
Fixes #72507
Alternative to #72454
Keeps the editor minimum height just tall enough to fit all notes.
Before
height.before.mp4
After
height.after.mp4