Skip to content

Commit 10f7719

Browse files
authored
fix: Remove empty space in embed apps when nav is set to sidebar (#23971)
## Description When the navigation was set to sidebar and you tried to embed the app, the sidebar wouldn't show up but the canvas had some empty left margin. This PR fixes that. #### PR fixes following issue(s) Fixes #23190 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing #### How Has This Been Tested? - [x] Manual - [ ] Jest - [ ] Cypress #### 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 - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] 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
1 parent f6b70f1 commit 10f7719

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/client/src/pages/AppViewer/AppPage.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { NAVIGATION_SETTINGS } from "constants/AppConstants";
1515
import { PageView, PageViewContainer } from "./AppPage.styled";
1616
import { useIsMobileDevice } from "utils/hooks/useDeviceDetect";
1717
import { APP_MODE } from "entities/App";
18+
import { useLocation } from "react-router";
1819

1920
type AppPageProps = {
2021
appName?: string;
@@ -31,6 +32,11 @@ export function AppPage(props: AppPageProps) {
3132
const isMobile = useIsMobileDevice();
3233
const appMode = useSelector(getAppMode);
3334
const isPublished = appMode === APP_MODE.PUBLISHED;
35+
const { search } = useLocation();
36+
const queryParams = new URLSearchParams(search);
37+
const isEmbed = queryParams.get("embed");
38+
const isNavbarVisibleInEmbeddedApp = queryParams.get("navbar");
39+
const isEmbeddedAppWithNavVisible = isEmbed && isNavbarVisibleInEmbeddedApp;
3440

3541
useDynamicAppLayout();
3642

@@ -51,7 +57,9 @@ export function AppPage(props: AppPageProps) {
5157
isAppSidebarPinned
5258
}
5359
isPublished={isPublished}
54-
sidebarWidth={isMobile ? 0 : sidebarWidth}
60+
sidebarWidth={
61+
isMobile || (isEmbed && !isEmbeddedAppWithNavVisible) ? 0 : sidebarWidth
62+
}
5563
>
5664
<PageView className="t--app-viewer-page" width={props.canvasWidth}>
5765
{props.widgetsStructure.widgetId &&

app/client/src/utils/hooks/useDynamicAppLayout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { scrollbarWidth } from "utils/helpers";
4040
import { useWindowSizeHooks } from "./dragResizeHooks";
4141
import type { AppState } from "@appsmith/reducers";
4242
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
43+
import { useLocation } from "react-router";
4344

4445
const GUTTER_WIDTH = 72;
4546
export const AUTOLAYOUT_RESIZER_WIDTH_BUFFER = 40;
@@ -69,6 +70,10 @@ export const useDynamicAppLayout = () => {
6970
(state: AppState) => state.ui.widgetDragResize.isAutoCanvasResizing,
7071
);
7172
const [isCanvasResizing, setIsCanvasResizing] = useState<boolean>(false);
73+
const { search } = useLocation();
74+
const queryParams = new URLSearchParams(search);
75+
const isEmbed = queryParams.get("embed");
76+
const isNavbarVisibleInEmbeddedApp = queryParams.get("navbar");
7277

7378
// /**
7479
// * calculates min height
@@ -147,17 +152,20 @@ export const useDynamicAppLayout = () => {
147152
* If there is
148153
* 1. a sidebar for navigation,
149154
* 2. it is pinned,
150-
* 3. and device is not mobile
155+
* 3. device is not mobile
156+
* 4. and it is not an embedded app
151157
* we need to subtract the sidebar width as well in the following modes -
152158
* 1. Preview
153159
* 2. App settings open with navigation tab
154160
* 3. Published
155161
*/
162+
const isEmbeddedAppWithNavVisible = isEmbed && isNavbarVisibleInEmbeddedApp;
156163
if (
157164
(appMode === APP_MODE.PUBLISHED ||
158165
isPreviewMode ||
159166
isAppSettingsPaneWithNavigationTabOpen) &&
160167
!isMobile &&
168+
(!isEmbed || isEmbeddedAppWithNavVisible) &&
161169
sidebarWidth
162170
) {
163171
calculatedWidth -= sidebarWidth;

0 commit comments

Comments
 (0)