Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize Popout to fit content on popout #557

Merged
merged 47 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
205c46b
Resize popout widgets to fit content
joehenry9498 Oct 24, 2023
e3e37c9
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Oct 24, 2023
db0da91
Changelogs
joehenry9498 Oct 24, 2023
6724b99
Move size calculation to internal method
joehenry9498 Oct 25, 2023
56b3ad8
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Oct 25, 2023
0087bde
Update ui/appui-react/src/appui-react/childwindow/InternalChildWindow…
joehenry9498 Oct 25, 2023
e4f1a20
Resize only takes effect on intial popout
joehenry9498 Oct 26, 2023
f512cca
Merge branch 'joeh/resizePopout' of https://github.com/iTwin/appui in…
joehenry9498 Oct 26, 2023
bf0081e
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Oct 26, 2023
7ff80ff
extract-api
joehenry9498 Oct 26, 2023
8719f3e
Rush audit fixes
joehenry9498 Oct 27, 2023
d5e103c
Extract Api
joehenry9498 Oct 27, 2023
c74aee4
Revert "Rush audit fixes"
joehenry9498 Oct 30, 2023
c908a22
Move size calculation further into nine zone state
joehenry9498 Oct 30, 2023
ddd052f
Update FrontstageDef.tsx
joehenry9498 Oct 30, 2023
afe3d69
Add test coverage
joehenry9498 Oct 30, 2023
91ff25a
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Oct 30, 2023
61a851e
extract-api
joehenry9498 Oct 30, 2023
9ae5003
Rush change
joehenry9498 Oct 30, 2023
cf5ddde
Delete common/changes/@itwin/appui-layout-react/joeh-resizePopout_202…
joehenry9498 Oct 30, 2023
764d116
Delete common/changes/@itwin/appui-react/joeh-resizePopout_2023-10-24…
joehenry9498 Oct 30, 2023
33732fa
Update NextVersion.md
joehenry9498 Oct 30, 2023
9170265
Change playwright test
joehenry9498 Oct 30, 2023
ada6798
Merge branch 'master' into joeh/resizePopout
joehenry9498 Oct 30, 2023
0aaac0e
Uneeded test changes
joehenry9498 Oct 30, 2023
383bcd1
Set min width for error boundary so that it appears in content renderer
joehenry9498 Oct 31, 2023
a301adf
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Oct 31, 2023
f8fc3ab
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Oct 31, 2023
7619f57
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Nov 1, 2023
17a9e8e
Check size of popout when fitting to container in test
joehenry9498 Nov 1, 2023
80f5216
Delete common/changes/@itwin/appui-layout-react/joeh-resizePopout_202…
joehenry9498 Nov 2, 2023
a36078b
Delete common/changes/@itwin/appui-react/joeh-resizePopout_2023-10-30…
joehenry9498 Nov 2, 2023
8e7d4d4
Remove popout container and popout to floating widget bounds
joehenry9498 Nov 2, 2023
d297cad
Merge branch 'joeh/resizePopout' of https://github.com/iTwin/appui in…
joehenry9498 Nov 2, 2023
d91c609
Refactor changelogs
joehenry9498 Nov 2, 2023
13c14a7
When preferredFloatingWidgetSize not set, will popout to content cont…
joehenry9498 Nov 2, 2023
6b217a1
Update ui/appui-layout-react/src/appui-layout-react/state/NineZoneSta…
joehenry9498 Nov 6, 2023
81b3eea
Merge remote-tracking branch 'origin/master' into joeh/resizePopout
joehenry9498 Nov 6, 2023
d92fe8e
Update joeh-resizePopout_2023-11-02-18-19.json
joehenry9498 Nov 6, 2023
b01fcba
Update NextVersion.md
joehenry9498 Nov 6, 2023
7f84fb3
Change inital size of popout in test
joehenry9498 Nov 6, 2023
cf24351
Update joeh-resizePopout_2023-11-02-18-19.json
joehenry9498 Nov 6, 2023
db0f0a4
Update joeh-resizePopout_2023-11-02-18-19.json
joehenry9498 Nov 6, 2023
90df9dc
Update NextVersion.md
joehenry9498 Nov 6, 2023
88913a1
Update NextVersion.md
joehenry9498 Nov 6, 2023
899004c
Updated screenshot for failing test
joehenry9498 Nov 6, 2023
9ad6104
Fix broken screenshot
joehenry9498 Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-layout-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/appui-layout-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-react",
"comment": "Popout widgets will now popout to preferredFloatingWidgetSize. Will popout to container size if preferredFloatingWidgetSize is not set",
"type": "none"
}
],
"packageName": "@itwin/appui-react"
}
1 change: 1 addition & 0 deletions docs/changehistory/NextVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Table of contents:
### Changes

- `AppNotificationManager` no longer requires `StatusBar` to be rendered in the active frontstage to show messages.
- Popout widgets will now popout to `preferredFloatingWidgetSize`. Will popout to container size if `preferredFloatingWidgetSize` is not set.

### Fixes

Expand Down
4 changes: 2 additions & 2 deletions full-stack-tests/ui/tests/popout-widget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ test.describe("popout widget", () => {
await expect(popoutPage).toHaveTitle(/View Attributes/);

expect(popoutPage.viewportSize()).toEqual({
height: 800,
width: 600,
height: 270,
width: 218,
});

// Update widget size and close the popout.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,31 @@ export function NineZoneStateReducer(
if (location && isPopoutTabLocation(location)) return state;

const savedTab = state.savedTabs.byId[id];

const tab = state.tabs[id];

let contentHeight = 800;
let contentWidth = 600;

if (tab.preferredFloatingWidgetSize) {
contentWidth = tab.preferredFloatingWidgetSize.width;
contentHeight = tab.preferredFloatingWidgetSize.height;
} else {
const popoutContentContainer = document.getElementById(
`content-container:${id}`
);
if (popoutContentContainer !== null) {
contentWidth = popoutContentContainer.offsetWidth + 20;
contentHeight = popoutContentContainer.offsetHeight + 20;
}
}

let preferredBounds = savedTab?.popoutBounds
? Rectangle.create(savedTab.popoutBounds)
: Rectangle.createFromSize({ height: 800, width: 600 });
: Rectangle.createFromSize({
height: contentHeight,
width: contentWidth,
});
if (size) preferredBounds = preferredBounds.setSize(size);
if (position) preferredBounds = preferredBounds.setPosition(position);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ export function WidgetContentRenderer(props: WidgetContentRendererProps) {
};
}, [renderTo, widgetContentManager, props.tabId]);
return ReactDOM.createPortal(
<TabIdContext.Provider value={props.tabId}>
{props.children}
</TabIdContext.Provider>,
<div
style={{ height: "100%", width: "100%" }}
id={`content-container:${props.tabId}`}
>
<TabIdContext.Provider value={props.tabId}>
{props.children}
</TabIdContext.Provider>
</div>,
container.current
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { addTabs } from "../Utils";
import { createDraggedTabState } from "../../appui-layout-react/state/internal/TabStateHelpers";
import { updatePanelState } from "../../appui-layout-react/state/internal/PanelStateHelpers";
import { assert } from "@itwin/core-bentley";
import { stub } from "sinon";

describe("NineZoneStateReducer", () => {
it("should not update for unhandled action", () => {
Expand Down Expand Up @@ -1619,6 +1620,52 @@ describe("NineZoneStateReducer", () => {
widgetIndex: 0,
});
});

it("should popout a tab and fit to preferredFloatingWidgetSize if bounds are not set", () => {
let state = createNineZoneState();
state = addTab(state, "t1", {
preferredFloatingWidgetSize: { width: 50, height: 50 },
});
state = addPanelWidget(state, "left", "w1", ["t1"]);

const newState = NineZoneStateReducer(state, {
type: "WIDGET_TAB_POPOUT",
id: "t1",
});
newState.popoutWidgets.allIds.should.length(1);
const popoutWidgetId = newState.popoutWidgets.allIds[0];
newState.popoutWidgets.byId[popoutWidgetId].bounds.should.eql({
left: 0,
top: 0,
bottom: 50,
right: 50,
});
});

it("should popout a tab and fit to content container if preferredFloatingWidgetSize is not set", () => {
let state = createNineZoneState();

const blankHTML = document.createElement("div");

stub(document, "getElementById").returns(blankHTML);
state = addTab(state, "t1");
state = addPanelWidget(state, "left", "w1", ["t1"]);

const newState = NineZoneStateReducer(state, {
type: "WIDGET_TAB_POPOUT",
id: "t1",
});

newState.popoutWidgets.allIds.should.length(1);
raplemie marked this conversation as resolved.
Show resolved Hide resolved
const popoutWidgetId = newState.popoutWidgets.allIds[0];

newState.popoutWidgets.byId[popoutWidgetId].bounds.should.eql({
left: 0,
top: 0,
bottom: 20,
right: 20,
});
});
});

describe("WIDGET_TAB_HIDE", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface PopoutWidgetProps {
widgetDef: WidgetDef;
}

/** Component used to wrap a widget for use is a child window.
/** Component used to wrap a widget for use in a child window.
* @internal
*/
export function PopoutWidget({
Expand Down
Loading