## Description This PR changes the CSS transitions on different components so that it prevents the Disturbed canvas issue on chrome.. #### PR fixes following issue(s) Fixes #25697 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? This fix has been tested manually. Since the issue is inconsistent automated tests cannot be added #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
103 lines
3.2 KiB
TypeScript
103 lines
3.2 KiB
TypeScript
import log from "loglevel";
|
|
import React from "react";
|
|
import styled from "styled-components";
|
|
import * as Sentry from "@sentry/react";
|
|
import { useSelector } from "react-redux";
|
|
import WidgetFactory from "utils/WidgetFactory";
|
|
import type { CanvasWidgetStructure } from "widgets/constants";
|
|
|
|
import { RenderModes } from "constants/WidgetConstants";
|
|
import useWidgetFocus from "utils/hooks/useWidgetFocus";
|
|
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
|
|
import { previewModeSelector } from "selectors/editorSelectors";
|
|
import { getSelectedAppTheme } from "selectors/appThemingSelectors";
|
|
import { getViewportClassName } from "utils/autoLayout/AutoLayoutUtils";
|
|
import {
|
|
ThemeProvider as WDSThemeProvider,
|
|
useTheme,
|
|
} from "@design-system/theming";
|
|
import { getIsAppSettingsPaneWithNavigationTabOpen } from "selectors/appSettingsPaneSelectors";
|
|
|
|
interface CanvasProps {
|
|
widgetsStructure: CanvasWidgetStructure;
|
|
pageId: string;
|
|
canvasWidth: number;
|
|
isAutoLayout?: boolean;
|
|
}
|
|
|
|
const Container = styled.section<{
|
|
background: string;
|
|
width: number;
|
|
$isAutoLayout: boolean;
|
|
}>`
|
|
background: ${({ background }) => background};
|
|
width: ${({ $isAutoLayout, width }) =>
|
|
$isAutoLayout ? `100%` : `${width}px`};
|
|
`;
|
|
const Canvas = (props: CanvasProps) => {
|
|
const { canvasWidth } = props;
|
|
const isPreviewMode = useSelector(previewModeSelector);
|
|
const isAppSettingsPaneWithNavigationTabOpen = useSelector(
|
|
getIsAppSettingsPaneWithNavigationTabOpen,
|
|
);
|
|
const selectedTheme = useSelector(getSelectedAppTheme);
|
|
const isWDSV2Enabled = useFeatureFlag("ab_wds_enabled");
|
|
const { theme } = useTheme({
|
|
borderRadius: selectedTheme.properties.borderRadius.appBorderRadius,
|
|
seedColor: selectedTheme.properties.colors.primaryColor,
|
|
});
|
|
|
|
/**
|
|
* background for canvas
|
|
*/
|
|
let backgroundForCanvas;
|
|
|
|
if (isPreviewMode || isAppSettingsPaneWithNavigationTabOpen) {
|
|
if (isWDSV2Enabled) {
|
|
backgroundForCanvas = "var(--color-bg)";
|
|
} else {
|
|
backgroundForCanvas = "initial";
|
|
}
|
|
} else {
|
|
if (isWDSV2Enabled) {
|
|
backgroundForCanvas = "var(--color-bg)";
|
|
} else {
|
|
backgroundForCanvas = selectedTheme.properties.colors.backgroundColor;
|
|
}
|
|
}
|
|
|
|
const focusRef = useWidgetFocus();
|
|
|
|
const marginHorizontalClass = props.isAutoLayout ? `mx-0` : `mx-auto`;
|
|
const paddingBottomClass = props.isAutoLayout ? "" : "pb-52";
|
|
try {
|
|
return (
|
|
<WDSThemeProvider theme={theme}>
|
|
<Container
|
|
$isAutoLayout={!!props.isAutoLayout}
|
|
background={backgroundForCanvas}
|
|
className={`relative t--canvas-artboard ${paddingBottomClass} transition-all duration-400 ${marginHorizontalClass} ${getViewportClassName(
|
|
canvasWidth,
|
|
)}`}
|
|
data-testid="t--canvas-artboard"
|
|
id="art-board"
|
|
ref={focusRef}
|
|
width={canvasWidth}
|
|
>
|
|
{props.widgetsStructure.widgetId &&
|
|
WidgetFactory.createWidget(
|
|
props.widgetsStructure,
|
|
RenderModes.CANVAS,
|
|
)}
|
|
</Container>
|
|
</WDSThemeProvider>
|
|
);
|
|
} catch (error) {
|
|
log.error("Error rendering DSL", error);
|
|
Sentry.captureException(error);
|
|
return null;
|
|
}
|
|
};
|
|
|
|
export default Canvas;
|