Skip to content

Conversation

@talissoncosta
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #6544

Adds a loading state check for the MultiSelect component in RuleConditionValueInput to prevent crashes when opening the Create Segment modal with environment-based operators.

Root Cause: When showMultiEnvironmentSelect is true but projectId is undefined or environments haven't loaded yet, react-select crashes internally with:

  • Chrome: TypeError: Cannot read properties of null (reading 'reduce')
  • Safari: null is not an object (evaluating 'e.options.reduce')

Fix:

  • Added isLoading check for when projectId is undefined or data?.results hasn't loaded
  • When loading: disable the MultiSelect, show "Loading environments..." placeholder, and use empty selectedValues
  • When loaded: normal behaviour with environments available

Sentry Issues:

  • FLAGSMITH-FRONTEND-4G8 - 3 events, 1 user
  • FLAGSMITH-FRONTEND-4G9 - 2 events, 1 user
  • FLAGSMITH-FRONTEND-4DP - 1 event, 1 user
  • FLAGSMITH-FRONTEND-4DQ - 1 event, 1 user

How to reproduce

  1. Navigate to a project's Segments page (/project/{id}/segments)
  2. Click "Create Segment" button
  3. Add a rule condition
  4. Select the property environment
  5. Select an operator that triggers multi-environment selection (e.g., IN, NOT_IN)
  6. Before fix: Modal crashes with TypeError
  7. After fix: MultiSelect shows "Loading environments..." until data is ready, then displays environment options

Alternative reproduction (simulating the race condition):

  1. Open Chrome DevTools → Network tab
  2. Set throttling to "Slow 3G"
  3. Follow steps 1-5 above
  4. The loading state should be visible briefly before environments load

How did you test this code?

  • ESLint passed via pre-commit hook
  • Manual testing following the reproduction steps above
  • Verified the MultiSelect displays correctly once environments are loaded
  • Verified the disabled state prevents interaction while loading

Fixes #6544

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@talissoncosta talissoncosta requested a review from a team as a code owner January 20, 2026 23:41
@talissoncosta talissoncosta requested review from kyle-ssg and removed request for a team January 20, 2026 23:41
@vercel
Copy link

vercel bot commented Jan 20, 2026

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

Project Deployment Review Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jan 20, 2026 11:43pm
flagsmith-frontend-staging Ready Ready Preview, Comment Jan 20, 2026 11:43pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Ignored Ignored Jan 20, 2026 11:43pm

Request Review

@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard fix labels Jan 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-6565 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-6565 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-6565 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-6565 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-6565 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-6565 Finished ✅ Results

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

Labels

fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: TypeError when opening Create Segment modal with environment-based operators

2 participants