Skip to content

Conversation

@talissoncosta
Copy link
Contributor

@talissoncosta talissoncosta commented Nov 4, 2025

Contributes to #5835


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

  • 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?
  • I have used a Conventional Commit title for this Pull Request

Changes

image image image image

Please describe.

How did you test this code?

Please describe.


Note

Adds multi-select for environment names (IN) and single-select (EQUAL/NOT_EQUAL) in segment rules, with cached condition values and minor UI/style tweaks.

  • Segments: Rules
    • Input types: RuleConditionValueInput now uses MultiSelect for IN on $.environment.name and EnvironmentSelectDropdown for EQUAL/NOT_EQUAL; loads environment options via useGetEnvironmentsQuery and parses arrays with safeParseArray.
    • State handling: Introduces useConditionCache to cache/restore condition values when changing operator/property; integrated into Rule.tsx.
    • Hooks: Adds useConditionInputType and exports via hooks/index.ts; simplifies useRuleContext (removes env dropdown logic).
    • UI: Refactors RuleConditionRow layout (grid classes), passes property to value input.
  • Components
    • MultiSelect: Styling/behavior tweaks (24px chip height, w-100, smaller gaps, conditional components, className handling).
    • Select wrapper: Preserves className on container.
  • Modals
    • CreateSegmentRulesTabForm, CreateSegment, CreateSegmentUsersTabContent, AssociatedSegmentOverrides: Layout adjustments (responsive columns, col-4 env selects) and spacing tweaks.
  • Styles
    • react-select: Use min-height for control; extensible value container unchanged; segment rule select width set to 100%.

Written by Cursor Bugbot for commit 006eb98. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Nov 4, 2025

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

Project Deployment Preview Comments Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview Comment Nov 6, 2025 1:16pm
flagsmith-frontend-staging Ready Ready Preview Comment Nov 6, 2025 1:16pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Ignored Ignored Preview Nov 6, 2025 1:16pm


render() {
const props = this.props
const { className, ...props } = this.props
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had an issue in here, className was being applied for the container and also for the Select component, passed as {...props}. Now I am extracting it to apply only for the container, that in my view was the goal in here.

@talissoncosta talissoncosta force-pushed the feat/multi-select-dropdown branch from 9b83d0f to de201f4 Compare November 4, 2025 22:21
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Nov 4, 2025
@talissoncosta talissoncosta force-pushed the feat/multi-select-dropdown branch from de201f4 to 1cd271f Compare November 4, 2025 22:41
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Nov 4, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Nov 4, 2025
@talissoncosta talissoncosta force-pushed the feat/multi-select-dropdown branch from 411d490 to 006eb98 Compare November 4, 2025 23:11
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Nov 4, 2025
@talissoncosta talissoncosta marked this pull request as ready for review November 4, 2025 23:17
@talissoncosta talissoncosta requested a review from a team as a code owner November 4, 2025 23:17
@talissoncosta talissoncosta removed the request for review from a team November 4, 2025 23:17
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Nov 5, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Runtime error with undefined updates.value during split

Potential runtime error when changing to PERCENTAGE_SPLIT operator. If updates.value is undefined (when no prior conditions set it) or null (when hideValue was true), the expression updates.value?.toString().split(':')[0] will fail. The optional chaining updates.value?.toString() returns undefined when updates.value is null/undefined, and then calling .split(':') on undefined throws a TypeError. The code should check if updates.value exists before calling split, or handle the undefined case explicitly.

frontend/web/components/segments/Rule/Rule.tsx#L116-L117

Fix in Cursor Fix in Web


Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Guard Clause: Fix Nullo Value Split Failure

When changing operator to PERCENTAGE_SPLIT, if updates.value is null (which happens when changing from a hideValue operator), the expression updates.value?.toString().split(':')[0] will fail. The optional chaining ?. only short-circuits the toString() call, returning undefined, but then .split(':') is called on undefined which will throw a TypeError: "Cannot read property 'split' of undefined". The fix should chain the split call as well: updates.value?.toString()?.split(':')[0] or handle the null case explicitly before this block.

frontend/web/components/segments/Rule/Rule.tsx#L114-L115

} else {
updates.value = updates.value?.toString().split(':')[0]

Fix in Cursor Fix in Web


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

Labels

feature New feature or request front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants