mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* Mobile spacing fixes * Keep mobile selection toolbar sticky above the iOS keyboard The mobile selection toolbar positioned itself with absolute positioning and a bottom calc derived from the document body rect and visual viewport height. On iOS the layout viewport (which fixed/absolute elements anchor to) does not shrink when the software keyboard opens, only the visual viewport does, so the toolbar drifted and lagged relative to the keyboard. Anchor the toolbar with position: fixed; bottom: 0 and introduce useKeyboardStickyOffset, which translates it up by the gap between the layout and visual viewport bottoms. It recomputes on visual viewport resize/scroll and runs a short requestAnimationFrame loop so the toolbar glides with the keyboard's open/close animation, and re-applies after every render so parent re-renders cannot clobber the offset. --------- Co-authored-by: Claude <noreply@anthropic.com>
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { SubscriptionType } from "@shared/types";
|
|
import type Collection from "~/models/Collection";
|
|
import { DropdownMenu } from "~/components/Menu/DropdownMenu";
|
|
import { OverflowMenuButton } from "~/components/Menu/OverflowMenuButton";
|
|
import { ActionContextProvider } from "~/hooks/useActionContext";
|
|
import useRequest from "~/hooks/useRequest";
|
|
import useStores from "~/hooks/useStores";
|
|
import { useCollectionMenuAction } from "~/hooks/useCollectionMenuAction";
|
|
|
|
type Props = {
|
|
collection: Collection;
|
|
align?: "start" | "end";
|
|
neutral?: boolean;
|
|
onRename?: () => void;
|
|
onOpen?: () => void;
|
|
onClose?: () => void;
|
|
};
|
|
|
|
function CollectionMenu({
|
|
collection,
|
|
align,
|
|
neutral,
|
|
onRename,
|
|
onOpen,
|
|
onClose,
|
|
}: Props) {
|
|
const { subscriptions } = useStores();
|
|
const { t } = useTranslation();
|
|
|
|
const {
|
|
loading: subscriptionLoading,
|
|
loaded: subscriptionLoaded,
|
|
request: loadSubscription,
|
|
} = useRequest(() =>
|
|
subscriptions.fetchOne({
|
|
collectionId: collection.id,
|
|
event: SubscriptionType.Document,
|
|
})
|
|
);
|
|
|
|
const handlePointerEnter = React.useCallback(() => {
|
|
if (!subscriptionLoading && !subscriptionLoaded) {
|
|
void loadSubscription();
|
|
}
|
|
}, [subscriptionLoading, subscriptionLoaded, loadSubscription]);
|
|
|
|
const rootAction = useCollectionMenuAction({
|
|
collectionId: collection.id,
|
|
onRename,
|
|
});
|
|
|
|
return (
|
|
<ActionContextProvider value={{ activeModels: [collection] }}>
|
|
<DropdownMenu
|
|
action={rootAction}
|
|
align={align}
|
|
onOpen={onOpen}
|
|
onClose={onClose}
|
|
ariaLabel={t("Collection options")}
|
|
>
|
|
<OverflowMenuButton
|
|
neutral={neutral}
|
|
onPointerEnter={handlePointerEnter}
|
|
/>
|
|
</DropdownMenu>
|
|
</ActionContextProvider>
|
|
);
|
|
}
|
|
|
|
export default observer(CollectionMenu);
|