Skip to content

Commit

Permalink
Fix useWidget hook issue when used in a popout widget (#1171)
Browse files Browse the repository at this point in the history
* Fix useWidget hook issue.

* rush change

* Fix test
  • Loading branch information
GerardasB authored Jan 15, 2025
1 parent 00e5268 commit b49eb79
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
10 changes: 10 additions & 0 deletions common/changes/@itwin/appui-react/issue-1170_2025-01-15-09-45.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-react",
"comment": "Fix `useWidget` hook issue when used in a popout widget.",
"type": "none"
}
],
"packageName": "@itwin/appui-react"
}
23 changes: 22 additions & 1 deletion e2e-tests/tests/popout-widget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ test.describe("popout widget", () => {
});

test("should dock a popout widget (after frontstage change)", async ({
context,
page,
}) => {
const tab = tabLocator(page, "WT-2");
Expand Down Expand Up @@ -243,3 +242,25 @@ test("should render after link styles are loaded", async ({
})
);
});

test("useWidget hook", async ({ page }) => {
await page.goto("./blank?frontstageId=widget-api");

// TODO: make sure the widget is not overlaid. Need to split into smaller test frontstages.
await setWidgetState(
page,
"appui-test-providers:UseWidgetHookWidget",
WidgetState.Floating
);

const tab = tabLocator(page, "Use Widget Hook");
const widget = floatingWidgetLocator({
tab,
});

const popoutPage = await popoutWidget(widget);
const widgetText = popoutPage.getByText(
`{"state":0,"widgetLocation":"popout"}`
);
await expect(widgetText).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ export class FrontstageDef {
content: popoutContent,
location: position,
useDefaultPopoutUrl: UiFramework.useDefaultPopoutUrl,
tabId,
});

// Use outer size if available to avoid inner size + browser zoom issues: https://github.com/iTwin/appui/issues/563
Expand Down

0 comments on commit b49eb79

Please sign in to comment.