Skip to content

fix(frontend): remove @material-ui/core dependency from AccordionCard#7025

Closed
nielskaspers wants to merge 2 commits intoFlagsmith:mainfrom
nielskaspers:fix/issue-7021-remove-material-ui
Closed

fix(frontend): remove @material-ui/core dependency from AccordionCard#7025
nielskaspers wants to merge 2 commits intoFlagsmith:mainfrom
nielskaspers:fix/issue-7021-remove-material-ui

Conversation

@nielskaspers
Copy link
Contributor

@nielskaspers nielskaspers commented Mar 24, 2026

Summary

Removes @material-ui/core and material-ui-chip-input dependencies by replacing all MUI components with lightweight alternatives.

Issue

Fixes #7021

Changes

  • Replaced MUI Collapse with a new CSS transition-based Collapse component
  • Replaced MUI IconButton with Flagsmith's own Button component
  • Rewrote ChipInput without material-ui-chip-input using native React
  • Replaced MUI Chip in ChipInput with native <span> elements
  • Replaced MUI SelectProps type in SegmentSelect with inline types
  • Removed @material-ui/core and material-ui-chip-input from dependencies and overrides
  • Regenerated package-lock.json

Testing

  • Verify AccordionCard expand/collapse animation works smoothly
  • Verify ChipInput in Create User modal accepts comma/space-separated values
  • Check no visual regressions in feature edit modals
  • Verify @material-ui/core and material-ui-chip-input are no longer in dependencies

Replace all @material-ui/core usages with native alternatives:
- AccordionCard: replace MUI Collapse with CSS transition-based Collapse
  component, replace MUI IconButton with project's own Button
- EventTextBlocks: replace MUI Collapse with new Collapse component
- SegmentSelect: replace MUI SelectProps type import with inline types
- ChipInput: replace MUI Chip with native span element

Add new lightweight Collapse component using CSS height transitions
with the same easing curve as MUI (cubic-bezier(0.4, 0, 0.2, 1)).

Remove @material-ui/core from dependencies and overrides in
package.json.

Fixes Flagsmith#7021
@nielskaspers nielskaspers requested a review from a team as a code owner March 24, 2026 07:13
@nielskaspers nielskaspers requested review from kyle-ssg and removed request for a team March 24, 2026 07:13
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

@vercel
Copy link

vercel bot commented Mar 24, 2026

@nielskaspers is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label Mar 24, 2026
- Replace material-ui-chip-input with native React implementation
- Remove material-ui-chip-input from dependencies
- Regenerate package-lock.json to sync with removed @material-ui/core
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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

setHeight(0)
})
})
}
Copy link

Choose a reason for hiding this comment

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

Collapse race condition from uncancelled requestAnimationFrame callbacks

Medium Severity

The else branch (collapsing) schedules nested requestAnimationFrame callbacks that call setHeight(0), but no cleanup function is returned from this branch. If open toggles back to true before those callbacks fire, the stale setHeight(0) will execute during the expand phase, snapping the content to zero height mid-animation. The if branch correctly returns a cleanup to clear its timer, but the else branch's requestAnimationFrame handles are never cancelled via cancelAnimationFrame.

Fix in Cursor Fix in Web

>
<IonIcon icon={close} />
</span>
</span>
Copy link

Choose a reason for hiding this comment

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

Delete click bubbles up triggering chip click handler

Medium Severity

The MUI Chip component internally called event.stopPropagation() on the delete icon click, preventing the chip's onClick from also firing. The replacement <span> structure nests the delete handler (onClick={handleDelete}) inside the chip's onClick={handleClick}, so clicking delete now triggers both handlers due to event bubbling. This is a behavioral regression from the MUI Chip replacement.

Fix in Cursor Fix in Web

@cursor
Copy link

cursor bot commented Mar 24, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@talissoncosta talissoncosta requested review from talissoncosta and removed request for kyle-ssg March 24, 2026 12:08
@talissoncosta talissoncosta self-assigned this Mar 24, 2026
@talissoncosta
Copy link
Contributor

Thanks for the contribution! Removing @material-ui/core is definitely something we want to do — it's been deprecated since 2021 and we only use it in a handful of places.

However, after smoke testing the branch, we found that the ChipInput rewrite has visual regressions — the chips and input aren't laid out correctly. The root cause is that the existing SCSS is tightly coupled to MUI's generated class names (.MuiChip-root, .MuiFormControl-root, .WAMuiChipInput-*), so replacing the components also requires rewriting the styles.

We're currently working on introducing semantic colour tokens and Storybook to the codebase. We're going to close this for now and revisit #7021 once that groundwork is in place, so we can:

  1. Replace the hardcoded colour variables in the MUI overrides with semantic tokens
  2. Visually validate the replacements in Storybook before merging

Appreciate the effort — the overall approach is sound, it's just a matter of timing. We'll reference your work when we pick this back up.

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

Labels

front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove @material-ui/core dependency from AccordionCard

2 participants