Skip to content

refactor(ui): Use existing organizationMemberships and remove infinite scrolling#8350

Merged
wobsoriano merged 10 commits intomainfrom
rob/sdk-63-hidden-org-selector-still-triggers-organization-check
Apr 17, 2026
Merged

refactor(ui): Use existing organizationMemberships and remove infinite scrolling#8350
wobsoriano merged 10 commits intomainfrom
rob/sdk-63-hidden-org-selector-still-triggers-organization-check

Conversation

@wobsoriano
Copy link
Copy Markdown
Member

@wobsoriano wobsoriano commented Apr 17, 2026

Description

When the Organizations feature was disabled in the dashboard, the OAuth consent screen triggered the "Organizations feature required" dev dialog. This happened because useOrganizationList was called unconditionally whenever enableOrgSelection was set — even passing undefined to the hook still invokes useAttemptToEnableOrganizations internally.

The fix replaces useOrganizationList entirely with user.organizationMemberships, which is populated synchronously from the user object alongside the initial session load. The FAPI includes the full, unpaginated list of memberships in the user response (confirmed in the Go backend — no cap or truncation), so we get everything needed (org id, name, imageUrl) with no extra fetch, no loading state, and no spinner.

The org select is now gated on both ctx.enableOrgSelection and organizationSettings.enabled, and renders immediately without pop-in.

Resolves SDK-63

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

…s disabled

When the Organizations feature was disabled in the dashboard, the OAuth
consent screen triggered the "Organizations feature required" dev dialog
because useOrganizationList was called unconditionally whenever
enableOrgSelection was set.

Extracts the hook and OrgSelect into a child component (OrgSelection)
that only mounts when organizationSettings.enabled is true, so the hook
never fires on disabled instances.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Apr 17, 2026 7:19pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 17, 2026

🦋 Changeset detected

Latest commit: 7c32196

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clerk/ui Patch
@clerk/chrome-extension Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the ui label Apr 17, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

📝 Walkthrough

Walkthrough

Adds a changeset for @clerk/ui (patch). In the OAuth consent UI, organization options are now derived directly from user.organizationMemberships instead of calling useOrganizationList; the component no longer waits on memberships loading and removes infinite-scroll/loading behavior from OrgSelect. Tests were updated to remove mocks for useOrganizationList and useInView, relying on fixtures that provide organization memberships. Types and component props were adjusted to remove pagination-related fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main changes: replacing useOrganizationList with user.organizationMemberships and removing infinite scrolling functionality.
Description check ✅ Passed The pull request description clearly relates to the changeset by explaining the bug fix that replaces useOrganizationList with user.organizationMemberships to prevent the Organizations feature dialog from triggering when the feature is disabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 17, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8350

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8350

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8350

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8350

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8350

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8350

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8350

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8350

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8350

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8350

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8350

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8350

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8350

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8350

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8350

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8350

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8350

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8350

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8350

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8350

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8350

commit: 7c32196

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ui/src/components/OAuthConsent/OAuthConsent.tsx`:
- Around line 37-76: Add a regression test that covers the
disabled-organizations path where enableOrgSelection=true but
organizationSettings.enabled=false: create a unit/test rendering of the
OAuthConsent flow (or the OrgSelection consumer) that stubs/mocks
useOrganizationList to return memberships and organizationSettings to have
enabled=false, then assert that the developer/org selection dialog does not open
and that OrgSelect (component OrgSelect and hidden input organization_id) is not
rendered; repeat similar assertions for the other referenced branches (lines
~88-90, 160-175, 274-279) to ensure coverage for the disabled organization
branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 12d5ad94-6965-49e9-a7a7-e4753efaad02

📥 Commits

Reviewing files that changed from the base of the PR and between 8c875a6 and fc9fc96.

📒 Files selected for processing (1)
  • packages/ui/src/components/OAuthConsent/OAuthConsent.tsx

Comment thread packages/ui/src/components/OAuthConsent/OAuthConsent.tsx Outdated
… to prevent spurious dev dialog

When enableOrgSelection is passed but the Organizations feature is disabled in the
dashboard, the component previously called useOrganizationList unconditionally which
triggered the "Organizations feature required" dev dialog. The fix moves the hook into
a child component (OrgSelectionGate) that only mounts when both flags are true, using a
context provider pattern to surface the org select node and hidden input to their
render sites without prop drilling. Tests updated to use f.withOrganizations() where
required and a new assertion confirms the hook is not called when orgs are disabled.
…ist for org select

Replaces the useOrganizationList hook with user.organizationMemberships, which is
populated synchronously from the user object and contains the complete list of memberships
without pagination. This eliminates the loading gate, the double spinner, and the
useAttemptToEnableOrganizations call that was triggering the dev dialog for instances
with the Organizations feature disabled. The org select is now gated on both
ctx.enableOrgSelection and organizationSettings.enabled, and renders immediately.
@wobsoriano wobsoriano marked this pull request as ready for review April 17, 2026 19:14
@wobsoriano wobsoriano changed the title fix(ui): prevent org-required dev dialog when organizations feature is disabled fix(ui): use user.organizationMemberships to fix org select dev dialog on disabled instances Apr 17, 2026
@wobsoriano wobsoriano changed the title fix(ui): use user.organizationMemberships to fix org select dev dialog on disabled instances refactor(ui): Use existing organizationMemberships and remove infinite scrolling Apr 17, 2026
footer={hasMore ? <InfiniteListSpinner ref={loadMoreRef} /> : null}
onReachEnd={hasMore ? onLoadMore : undefined}
/>
<SelectOptionList />
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will remove the added infinite scrolling props to this shared element in a follow up PR

@wobsoriano wobsoriano merged commit 22f0b27 into main Apr 17, 2026
52 checks passed
@wobsoriano wobsoriano deleted the rob/sdk-63-hidden-org-selector-still-triggers-organization-check branch April 17, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants