Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/@itwin-tree-widget-react-fancy-ears-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@itwin/tree-widget-react": patch
---

Fix tree widget header button skeletons not matching real component heights
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import { describe, it, vi } from "vitest";
import { page } from "vitest/browser";
import { TreeWidgetComponentImpl } from "../../tree-widget-react/TreeWidgetComponentImpl.js";
import { COLOR_SCHEMES, renderWithTheme, validateSnapshot } from "./RenderUtils.js";

vi.mock("@itwin/appui-react", () => ({
useActiveIModelConnection: () => ({ key: "test-imodel" }),
}));

COLOR_SCHEMES.forEach((colorScheme) => {
describe(`[${colorScheme}] <TreeWidgetComponentImpl />`, () => {
it("renders loading state", async () => {
await page.viewport(400, 300);
const { locator } = await renderWithTheme(
// `shouldShow` never resolves, so the widget stays in its loading state.
<TreeWidgetComponentImpl trees={[{ id: "tree", getLabel: () => "Tree", render: () => null, shouldShow: async () => new Promise(() => {}) }]} />,
{ colorScheme },
);
await validateSnapshot(locator);
});
});
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess the darwin screenshots got in by accident?

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -221,12 +221,12 @@ function LoadingTree() {
<SelectableTree
buttons={
<>
<Skeleton variant={"rounded"} width={28} height={28} />
<Skeleton variant={"rounded"} width={28} height={28} />
<Skeleton variant={"rounded"} width={28} height={28} />
<Skeleton variant={"rounded"} width={28} height={28} />
<Skeleton variant={"rounded"} width={28} height={28} />
<Skeleton variant={"rounded"} width={28} height={28} />
<Skeleton variant={"rounded"} width={24} height={24} />
<Skeleton variant={"rounded"} width={24} height={24} />
<Skeleton variant={"rounded"} width={24} height={24} />
<Skeleton variant={"rounded"} width={24} height={24} />
<Skeleton variant={"rounded"} width={24} height={24} />
<Skeleton variant={"rounded"} width={24} height={24} />
</>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function WidgetHeader({ defaultSelectedContentId, trees, onSelect, onSear
function LoadingHeader() {
return (
<div className="tw-content-header">
<Skeleton variant={"rounded"} className={"tw-content-header-search"} height={24} />
<Skeleton variant={"rounded"} className={"tw-content-header-selector"} height={24} />
<Skeleton variant={"rounded"} width={24} height={24} style={{ flexShrink: 0 }} />
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/tree-widget/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default defineConfig({
expect: {
toMatchScreenshot: {
comparatorName: "pixelmatch",
/* Any pixel differing by more than 5% (YIQ color distance) fails; tolerates only subtle antialiasing noise. */
comparatorOptions: { threshold: 0.05 },
/* Any pixel differing by more than 2% (YIQ color distance) fails; tolerates only subtle antialiasing noise. */
comparatorOptions: { threshold: 0.02 },
},
},
},
Expand Down
Loading