-
Notifications
You must be signed in to change notification settings - Fork 4
Fix popout widget restore state and enforce minimum popout size #1599
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
Open
arome
wants to merge
4
commits into
master
Choose a base branch
from
fix-popout-widget-restore-and-min-size
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
23914e9
Fix popout widget restore state and enforce minimum popout size
arome 1caed5b
Enhance widget visibility controls with state indication and improved…
arome 9cd6a41
Remove unnecessary blank line before dockWidgetContainer describe block
arome f5bcb70
Refactor minimum popout window size handling and centralize definition
arome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@itwin/appui-react": patch | ||
| --- | ||
|
|
||
| Fixed a popped-out (child window) widget docking back to its panel instead of remaining popped out after it was hidden (`WidgetState.Hidden`) and then shown again. | ||
|
|
||
| Also enforced a minimum popout window size (200x200), matching the existing minimum used for floating widgets, to prevent popout windows from progressively shrinking to an unusably small size across repeated pop-out/dock cycles. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
| * See LICENSE.md in the project root for license terms and full copyright notice. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import { PopoutRestoreStory } from "./PopoutRestore"; | ||
| import { AppUiDecorator } from "../Decorators"; | ||
| import { Page } from "../AppUiStory"; | ||
|
|
||
| const meta = { | ||
| title: "Widget/PopoutRestore", | ||
| component: PopoutRestoreStory, | ||
| tags: ["autodocs"], | ||
| decorators: [AppUiDecorator], | ||
| parameters: { | ||
| docs: { | ||
| page: () => <Page />, | ||
| }, | ||
| }, | ||
| } satisfies Meta<typeof PopoutRestoreStory>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| /** Steps to reproduce AB#2024472: | ||
| * 1. Pop the widget out (drag its tab out of the panel, or use the tab's | ||
| * "..." menu and click "Pop out active widget tab"). | ||
| * 2. Click "Hide widget". | ||
| * 3. Click "Show widget". | ||
| * | ||
| * Expected: the widget re-appears in its popout window. | ||
| * Before the fix it would instead dock back into the left panel. | ||
| */ | ||
| export const Default: Story = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
| * See LICENSE.md in the project root for license terms and full copyright notice. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
| import React from "react"; | ||
| import { | ||
| StagePanelState, | ||
| UiItemsProvider, | ||
| WidgetState, | ||
| useSpecificWidgetDef, | ||
| } from "@itwin/appui-react"; | ||
| import { Button } from "@itwin/itwinui-react"; | ||
| import { AppUiStory } from "../AppUiStory"; | ||
| import { createFrontstage, createWidget } from "../Utils"; | ||
|
|
||
| /** Demonstrates that a popped-out widget remains popped out after being hidden | ||
| * (e.g. because it has no content to display) and then shown again. | ||
| * | ||
| * The hide/show controls live outside of the widget (as `AppUiStory` children) | ||
| * since hiding the widget unmounts its content, which would otherwise take the | ||
| * "Show widget" button down with it. | ||
| * | ||
| * To reproduce: pop the widget out (drag its tab out, or use the "..." menu), | ||
| * then click "Hide widget" and "Show widget". Before the fix (AB#2024472) the | ||
| * widget would dock back into the panel instead of staying popped out. | ||
| */ | ||
| export function PopoutRestoreStory() { | ||
| const provider = { | ||
| id: "widgets", | ||
| getWidgets: () => [ | ||
| createWidget(1, { | ||
| canPopout: true, | ||
| content: <div style={{ padding: "0.5em" }}>Widget content</div>, | ||
| }), | ||
| ], | ||
| } satisfies UiItemsProvider; | ||
| return ( | ||
| <AppUiStory | ||
| itemProviders={[provider]} | ||
| frontstages={[ | ||
| createFrontstage({ | ||
| leftPanelProps: { | ||
| defaultState: StagePanelState.Open, | ||
| }, | ||
| }), | ||
| ]} | ||
| > | ||
| <WidgetVisibilityControls /> | ||
| </AppUiStory> | ||
| ); | ||
| } | ||
|
|
||
| function WidgetVisibilityControls() { | ||
| const widgetDef = useSpecificWidgetDef("w1"); | ||
| const [visible, setVisible] = React.useState(true); | ||
|
|
||
| const hide = () => { | ||
| setVisible(false); | ||
| widgetDef?.setWidgetState(WidgetState.Hidden); | ||
| }; | ||
| const show = () => { | ||
| setVisible(true); | ||
| widgetDef?.setWidgetState(WidgetState.Open); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| style={{ | ||
| position: "absolute", | ||
| bottom: 0, | ||
| left: 0, | ||
| zIndex: 1000, | ||
| padding: "0.5em", | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| gap: "0.5em", | ||
| }} | ||
| > | ||
| <div>Widget state: {visible ? "Visible" : "Hidden"}</div> | ||
| <div style={{ display: "flex", gap: "0.5em" }}> | ||
| <Button onClick={hide} size="small"> | ||
| Hide widget | ||
| </Button> | ||
| <Button onClick={show} styleType="cta" size="small"> | ||
| Show widget | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.