mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
fix: Selection toolbar not displaying on mobile
The mobile branch of FloatingToolbar rendered nothing until `position.visible` was true, but `usePosition` only reports a visible position once the menu element has been measured through `menuRef`. On desktop the wrapper is always mounted (it animates in via opacity) so the ref is populated on first render, while on mobile the toolbar is the only thing that mounts the ref — leaving it permanently null and the bar never displayed. Gate the mobile bar on there being toolbar content instead. Position is irrelevant on mobile: the bar is fixed to the bottom of the viewport and its vertical offset is owned by useKeyboardStickyOffset. Also size the bar with border-box and center its content vertically, so the declared 60px is the height of the bar rather than 60px of content plus padding with the buttons pinned to the top. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GhGyxA663bMFZ1NxBhLAoF
This commit is contained in:
1 file changed
+13
-5
@@ -268,7 +268,13 @@ const FloatingToolbar = React.forwardRef(function FloatingToolbar_(
|
||||
});
|
||||
|
||||
const isMobile = useMobile();
|
||||
const isMobileToolbarVisible = isMobile && !!props.active && position.visible;
|
||||
|
||||
// The mobile toolbar is a bar fixed to the bottom of the viewport, so it does
|
||||
// not depend on the measured position of the selection – only on the toolbar
|
||||
// being active with something to show. `position.visible` must not be used
|
||||
// here: it is only true once the menu element has been measured, and the
|
||||
// element is never mounted while this branch renders nothing.
|
||||
const isMobileToolbarVisible = isMobile && !!props.active && !!props.children;
|
||||
|
||||
// Keep the mobile toolbar glued to the top of the on-screen keyboard. The
|
||||
// hook tracks the visual viewport directly — see its implementation for the
|
||||
@@ -282,9 +288,7 @@ const FloatingToolbar = React.forwardRef(function FloatingToolbar_(
|
||||
return (
|
||||
<ReactPortal>
|
||||
<MobileWrapper ref={menuRef}>
|
||||
{props.children && (
|
||||
<MobileBackground>{props.children}</MobileBackground>
|
||||
)}
|
||||
<MobileBackground>{props.children}</MobileBackground>
|
||||
</MobileWrapper>
|
||||
</ReactPortal>
|
||||
);
|
||||
@@ -360,8 +364,12 @@ const MobileWrapper = styled.div`
|
||||
`;
|
||||
|
||||
const MobileBackground = styled.div`
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 10px 6px;
|
||||
height: 60px;
|
||||
min-height: 60px;
|
||||
background-color: ${s("menuBackground")};
|
||||
border-top: 1px solid ${s("divider")};
|
||||
|
||||
|
||||
Reference in new issue
Block a user