Merge master + post merge fixes.

This commit is contained in:
barnabasmolnar 2023-07-24 14:16:14 +02:00
commit 011b268dde
5 changed files with 36 additions and 6 deletions

View File

@ -1,7 +1,7 @@
name: Semantic PR title name: Semantic PR title
on: on:
pull_request_target: pull_request:
types: types:
- opened - opened
- edited - edited

View File

@ -4,6 +4,7 @@ import {
useExcalidrawSetAppState, useExcalidrawSetAppState,
useExcalidrawActionManager, useExcalidrawActionManager,
useExcalidrawElements, useExcalidrawElements,
useAppProps,
} from "../App"; } from "../App";
import { import {
ExportIcon, ExportIcon,
@ -198,13 +199,20 @@ export const ChangeCanvasBackground = () => {
const { t } = useI18n(); const { t } = useI18n();
const appState = useUIAppState(); const appState = useUIAppState();
const actionManager = useExcalidrawActionManager(); const actionManager = useExcalidrawActionManager();
const appProps = useAppProps();
if (appState.viewModeEnabled) { if (
appState.viewModeEnabled ||
!appProps.UIOptions.canvasActions.changeViewBackgroundColor
) {
return null; return null;
} }
return ( return (
<div style={{ marginTop: "0.5rem" }}> <div style={{ marginTop: "0.5rem" }}>
<div style={{ fontSize: ".75rem", marginBottom: ".5rem" }}> <div
data-testid="canvas-background-label"
style={{ fontSize: ".75rem", marginBottom: ".5rem" }}
>
{t("labels.canvasBackground")} {t("labels.canvasBackground")}
</div> </div>
<div style={{ padding: "0 0.625rem" }}> <div style={{ padding: "0 0.625rem" }}>

View File

@ -764,7 +764,11 @@ export default function App({ appTitle, useCustom, customArgs }: AppProps) {
gridModeEnabled={gridModeEnabled} gridModeEnabled={gridModeEnabled}
theme={theme} theme={theme}
name="Custom name of drawing" name="Custom name of drawing"
UIOptions={{ canvasActions: { loadScene: false } }} UIOptions={{
canvasActions: {
loadScene: false,
},
}}
renderTopRightUI={renderTopRightUI} renderTopRightUI={renderTopRightUI}
onLinkOpen={onLinkOpen} onLinkOpen={onLinkOpen}
onPointerDown={onPointerDown} onPointerDown={onPointerDown}

View File

@ -2,7 +2,7 @@
exports[`<Excalidraw/> <MainMenu/> should render main menu with host menu items if passed from host 1`] = ` exports[`<Excalidraw/> <MainMenu/> should render main menu with host menu items if passed from host 1`] = `
<div <div
aria-labelledby="radix-:r5v:" aria-labelledby="radix-:r65:"
aria-orientation="vertical" aria-orientation="vertical"
class="dropdown-menu main-menu-content" class="dropdown-menu main-menu-content"
data-align="start" data-align="start"
@ -12,7 +12,7 @@ exports[`<Excalidraw/> <MainMenu/> should render main menu with host menu items
data-state="open" data-state="open"
data-testid="dropdown-menu" data-testid="dropdown-menu"
dir="ltr" dir="ltr"
id="radix-:r60:" id="radix-:r66:"
role="menu" role="menu"
style="outline: none; --radix-dropdown-menu-content-transform-origin: var(--radix-popper-transform-origin); --radix-dropdown-menu-content-available-width: var(--radix-popper-available-width); --radix-dropdown-menu-content-available-height: var(--radix-popper-available-height); --radix-dropdown-menu-trigger-width: var(--radix-popper-anchor-width); --radix-dropdown-menu-trigger-height: var(--radix-popper-anchor-height); animation: none;" style="outline: none; --radix-dropdown-menu-content-transform-origin: var(--radix-popper-transform-origin); --radix-dropdown-menu-content-available-width: var(--radix-popper-available-width); --radix-dropdown-menu-content-available-height: var(--radix-popper-available-height); --radix-dropdown-menu-trigger-width: var(--radix-popper-anchor-width); --radix-dropdown-menu-trigger-height: var(--radix-popper-anchor-height); animation: none;"
tabindex="-1" tabindex="-1"
@ -604,6 +604,7 @@ exports[`<Excalidraw/> Test UIOptions prop Test canvasActions should render menu
style="margin-top: 0.5rem;" style="margin-top: 0.5rem;"
> >
<div <div
data-testid="canvas-background-label"
style="font-size: .75rem; margin-bottom: .5rem;" style="font-size: .75rem; margin-bottom: .5rem;"
> >
Canvas background Canvas background

View File

@ -204,6 +204,23 @@ describe("<Excalidraw/>", () => {
); );
//open menu //open menu
togglePopover("Main menu"); togglePopover("Main menu");
expect(queryByTestId(container, "canvas-background-label")).toBeNull();
expect(queryByTestId(container, "canvas-background-picker")).toBeNull();
});
it("should hide the canvas background picker even if passed if the `canvasActions.changeViewBackgroundColor` is set to false", async () => {
const { container } = await render(
<Excalidraw
UIOptions={{ canvasActions: { changeViewBackgroundColor: false } }}
>
<MainMenu>
<MainMenu.DefaultItems.ChangeCanvasBackground />
</MainMenu>
</Excalidraw>,
);
//open menu
togglePopover("Main menu");
expect(queryByTestId(container, "canvas-background-label")).toBeNull();
expect(queryByTestId(container, "canvas-background-picker")).toBeNull(); expect(queryByTestId(container, "canvas-background-picker")).toBeNull();
}); });