Skip to content

Fix slides org switching and form creation UX#2285

Closed
shomix wants to merge 8 commits into
mainfrom
ai_main_376c7c60fad048f28352
Closed

Fix slides org switching and form creation UX#2285
shomix wants to merge 8 commits into
mainfrom
ai_main_376c7c60fad048f28352

Conversation

@shomix

@shomix shomix commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes stale slide decks when switching organizations, and improves form creation UX with loading states and a corrected copy-link button.

Problem

In templates/slides, switching organizations did not refresh the deck list — slides from the previous organization stayed visible until a manual page refresh. In templates/forms, creating a new form navigated to a randomly generated temporary ID before the form actually existed, causing a "Failed to load form" error page, and the copy-link button in the form builder toolbar was shown (but disabled/unclickable) for unpublished forms, which was confusing.

Solution

  • Introduced an OrganizationScopedDeckProvider that remounts the DeckProvider whenever the active organization changes, ensuring deck state is reset per-organization.
  • Removed the temporary random ID navigation for form creation and instead navigate only after the form is successfully created, adding a loading indicator on the create buttons while the mutation is pending.
  • Hid the copy-share-link button entirely until a form is published, instead of showing it disabled.

Key Changes

  • Added OrganizationScopedDeckProvider.tsx in templates/slides/app/context, which keys DeckProvider on ${version}:${organizationScope} using useOrg() to force a remount on org change, plus a test verifying the remount behavior.
  • Updated templates/slides/app/root.tsx to use OrganizationScopedDeckProvider instead of DeckProvider directly in both the bare and full app layouts.
  • In templates/forms/app/components/layout/Sidebar.tsx and templates/forms/app/pages/FormsListPage.tsx: removed premature navigation using a random temp ID, navigate only in onSuccess of createForm.mutate, and added an IconLoader2 spinner plus disabled state on the create button while createForm.isPending.
  • In templates/forms/app/pages/FormBuilderPage.tsx: the copy public link button/tooltip is now only rendered when form.status === "published", removing the disabled state and status-conditional labels/tooltips.

Edit in Builder  Preview


To clone this PR locally use the Github CLI with command gh pr checkout 2285

You can tag me at @BuilderIO for anything you want me to fix or change

@netlify

This comment has been minimized.

@builder-io-integration builder-io-integration Bot changed the title Update from the Builder.io agent Fix slides org switching and form creation UX Jul 21, 2026
@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Visual recap — skipped

The visual recap job did not run for this pull request. This is informational only and does not block the PR.

Recap skipped for 12d5870: closed without merge.

builder-io-integration[bot]

This comment was marked as outdated.

@netlify

This comment has been minimized.

builder-io-integration[bot]

This comment was marked as outdated.

builder-io-integration[bot]

This comment was marked as outdated.

@shomix shomix closed this Jul 21, 2026

@builder-io-integration builder-io-integration Bot 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.

Builder reviewed your changes and found 1 potential issue 🟡

Review Details

Incremental Code Review Summary

The latest commit addresses the prior ordinary-route regression by flushing pending saves for normal unmounts and canceling only when the provider is marked as an organization-switch unmount. The added tests cover the committed loading, organization remount, and marker behavior. The previously reported ordinary-unmount cancellation comment was verified fixed and resolved.

Key Finding

  • 🟡 MEDIUM — The new org-switch marker is written to a module-global counter during render. If React starts and abandons/replays a concurrent render before commit, the marker can remain even though no provider cleanup occurred. A later ordinary unmount may consume that stale marker and cancel pending edits instead of flushing them, causing unrelated data loss.

The existing organization-switch pending-edit concern remains a separate open issue and is not reposted. Both app servers were healthy, but browser executors again lacked Chrome automation tools, so runtime verification was unavailable.

🧪 Browser testing: Attempted after this review; skipped because browser automation tooling was unavailable (dev server was running).

Comment on lines +44 to +50
if (prevScopeRef.current !== organizationScope) {
// Org scope changed: signal that the imminent DeckProvider unmount is an
// org switch so its cleanup cancels pending ops instead of flushing them.
// This runs during render (synchronously before React's commit phase), which
// guarantees the flag is set before the DeckProvider cleanup executes.
markOrgSwitchUnmount();
prevScopeRef.current = organizationScope;

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.

🟡 Do not record organization-switch cleanup during render

markOrgSwitchUnmount() mutates a module-global counter during render, but React may start and abandon or replay a concurrent render before the keyed provider commits its unmount. That can leave a stale marker behind; a later ordinary provider unmount may consume it and cancel pending saves instead of flushing them. Move the bookkeeping to a commit-phase mechanism and associate it with the specific provider cleanup rather than a global render-time counter.

Additional Info
Reported independently by 1 of 2 code-review agents; latest tests cover only committed synchronous rerenders.

Fix in Builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants