Repository navigation
[COMMS-1102] Documents: toolbar missing / not styled correctly on mobile - #26648
ihordubas99 merged 2 commits into
Conversation
bbb5d77 to
805541a
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
|
Hi @ihordubas99 |
805541a to
57012df
Compare
judithroth
left a comment
There was a problem hiding this comment.
Okay, on my Android device, the toolbar is now there 👏 but I can't open the dropdown where I can switch between paragraph, heading, etc.
On Browserstack iPhone 14, it seems like the dropdown opens below:
Since there is no gap on my Android device, it may that I don't see it because it also opens below.
While on BlockNote itself, it openes above:
Can you please check if this is due to us being a lower version than the BlockNote demo site or if it's a bug we need to fix?
95f3d94 to
89805a1
Compare
|
Hi @judithroth, thanks for the review and great catch! It's not the BlockNote version, there were two issues: Dropdown behind the keyboard (iOS + Android). Since Mantine 9.3 (we're on 9.7.4, the demo on 9.1.1), a popover that fits on neither side falls back to bottom instead of the side with more room. Fixed by disabling that via our own MantineProvider around the editor. Dropdown behind the page (Android). Mantine sets z-index: 300 on dropdowns, below our sticky mobile header (550). Fixed by making the body-level toolbar container a stacking context above the header. Also, every app on Mantine >= 9.3 should hit issue 1, so I'd open an issue at BlockNote. If they fix it, we can drop our provider. What do you think? |
Fully agree, please do that 👍 |
judithroth
left a comment
There was a problem hiding this comment.
Wow, you were able to fix that, nice 🤩
Ticket
https://community.openproject.org/wp/COMMS-1102
What are you trying to accomplish?
Since the BlockNote 0.55 bump, the formatting toolbar in Documents is broken on mobile:
After this PR, the toolbar on both platforms is styled, pinned above the virtual keyboard and horizontally scrollable, as BlockNote intends.
Screenshots
What approach did you choose and why?
Since 0.55, BlockNote's
FormattingToolbarControllerswitches to a newMobileFormattingToolbarControlleron touch devices while the virtual keyboard is open. That toolbar is portaled into a root ondocument.body, and the target is hardcoded (<PortalElementOverride target={document.body}>, still the same in 0.57). Two separate problems followed from that:1. No styles (iOS, Android)
Our editor lives in a shadow root, and
blocknote.csswas loaded only into that shadow root. The body-level toolbar is outside it, so none of the BlockNote/Mantine CSS applies.->
block-note-element.tsnow also addsblocknote.csstodocument.head, once (deduplicated byhref, so several editors or Turbo reconnects don't add it again). It's the same URL as in the shadow root, so the browser serves it from cache.I checked the built CSS for unscoped selectors: apart from
.bn-*/ Mantine classes, it only targets BlockNote attributes (data-content-type,data-text-color, …), which OpenProject uses only inside the editor. The rest of the page is unaffected.2. Covered by the page (Android)
_base_mobile.sassmakes everydiv:has(page-header)sticky withz-index: var(--main-menu-toggler-z-index)(550). That includes the whole.op-document-view, which then covers the toolbar (z-index: calc(var(--bn-ui-base-z-index) + 40)= 40). I confirmed this on a device via remote debugging:elementFromPointhit the document view, and raising the toolbar'sz-indexmade it appear.-> Set BlockNote's own
--bn-ui-base-z-indexto--main-menu-toggler-z-indexonbody > .block-note-editor-container, i.e. only the body-level portal root. That lifts the toolbar and its dropdowns, which portal into the same root. The editor inside the shadow root is untouched, becausebody >can't match there.Alternatives I rejected
DesktopFormattingToolbarController(forcing the floating toolbar): it renders inside the shadow root, but it drops BlockNote's mobile UX (toolbar pinned above the keyboard). It also has no width limit, so on a phone it's wider than the screen and its right part is cut off.Upstream
Reported as TypeCellOS/BlockNote#3304: let the mobile toolbar respect
portalElements.formattingToolbar. If that lands, change 1 can be removed. Change 2 stays either way, since the sticky header is ours.AI involvement
Collaborative – AI generated a substantial part of the code; I reviewed and understand every line.
Merge checklist