Skip to content

fix skeleton showing for declarative popup widgets - #68

Merged
Sam Beveridge (00salmon) merged 2 commits into
masterfrom
fast-follow
Apr 2, 2026
Merged

Sam Beveridge (00salmon) merged 2 commits into
masterfrom
fast-follow

Conversation

@00salmon

Copy link
Copy Markdown
Contributor

Description of the change

Description here

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation or Development tools (readme, specs, tests, code formatting)

Links

  • Jira issue number: (PUT IT HERE)
  • Process.st launch checklist: (PUT IT HERE)

Checklists

Development

  • Prettier was run (if applicable)
  • The behaviour changes in the pull request are covered by specs
  • All tests related to the changed code pass in development

Paperwork

  • This pull request has a descriptive title and information useful to a reviewer
  • This pull request has a Jira number
  • This pull request has a Process.st launch checklist

Code review

  • Changes have been reviewed by at least one other engineer
  • Security impacts of this change have been considered

Copilot AI review requested due to automatic review settings April 2, 2026 00:00
@github-actions

github-actions Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

A preview of a7b17be is uploaded and can be seen here:

✨ https://saasquatch.github.io/squatch-js/pull/68 ✨

@github-actions

github-actions Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
dist/squatch.js 13 KB (-0.04% 🔽)

@AndiLuo AndiLuo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks good to me!

@00salmon
Sam Beveridge (00salmon) merged commit b04cda8 into master Apr 2, 2026
5 of 6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the declarative widget loading behavior so popup web components don’t inject a visible loading skeleton into the component shadow DOM before the popup dialog exists (i.e., before the popup is opened), and adds automated coverage for the regression.

Changes:

  • Adjusted DeclarativeWidget.connectedCallback() to skip skeleton injection for POPUP widgets unless a dialog container already exists (re-render case).
  • Added a new automated feature scenario asserting no skeleton is injected/present for popup widgets before opening.
  • Implemented corresponding step definitions to pause rendering mid-load and assert skeleton absence.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

File Description
src/widgets/declarative/DeclarativeWidget.ts Changes skeleton injection logic for POPUP widgets to avoid pre-open skeleton display.
test/specs/DeclarativeWidgets.feature Adds a new automated scenario covering “no popup skeleton before open”.
test/step_definitions/DeclarativeWidgets.steps.ts Adds steps implementing the new scenario and assertions around skeleton absence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 350 to 354
const root = this.shadowRoot || this.attachShadow({ mode: "open" });

// For popup widgets, insert skeleton into the dialog container if it exists
// For popup widgets, only show skeleton inside an existing dialog (re-render case).
// On first render, skip skeleton since the popup isn't visible yet.
if (this.type === "POPUP") {

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

The skeleton HTML is still being imported/built unconditionally, but in the POPUP first-render path it’s now never appended anywhere. Consider restructuring so the dynamic import + skeletonContainer creation only happens when you’re actually going to inject a skeleton (EMBED always, POPUP only when an existing dialog container is found) to avoid unnecessary async work on initial popup load.

Copilot uses AI. Check for mistakes.
Comment on lines +1385 to +1387
// Give it time to potentially inject a skeleton, then confirm none exists
await new Promise((r) => setTimeout(r, 100));
const skeleton = el.shadowRoot?.getElementById("loading-skeleton");

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

This assertion can be flaky because it relies on a fixed 100ms delay and assumes shadowRoot is already attached; if the dynamic import in connectedCallback takes longer, el.shadowRoot may still be null (making the expectation fail), and the test could also miss a skeleton injected after 100ms but before the render pause is released. Prefer waiting for shadowRoot to exist (e.g., via waitUntil) and then asserting the skeleton never appears during the whole paused-loading window (or using a MutationObserver) instead of a hard-coded sleep.

Suggested change
// Give it time to potentially inject a skeleton, then confirm none exists
await new Promise((r) => setTimeout(r, 100));
const skeleton = el.shadowRoot?.getElementById("loading-skeleton");
await waitUntil(
() =>
el.shadowRoot !== null &&
el.shadowRoot.getElementById("loading-skeleton") === null,
"Expected shadowRoot to be attached without a loading skeleton"
);
const skeleton = el.shadowRoot!.getElementById("loading-skeleton");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants