diff --git a/packages/mui-codemod/src/deprecations/button-group-classes/button-group-classes.js b/packages/mui-codemod/src/deprecations/button-group-classes/button-group-classes.js index b64f856fdc07cb..440370cb47b623 100644 --- a/packages/mui-codemod/src/deprecations/button-group-classes/button-group-classes.js +++ b/packages/mui-codemod/src/deprecations/button-group-classes/button-group-classes.js @@ -106,14 +106,17 @@ export default function transformer(file, api, options) { }); }); - const selector = `${replacementSelectorPrefix}${deprecatedClass}`; + const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}(.|$)`); root - .find(j.Literal, (literal) => typeof literal.value === 'string' && literal.value === selector) + .find( + j.Literal, + (literal) => typeof literal.value === 'string' && literal.value.match(selectorRegex), + ) .forEach((path) => { path.replace( j.literal( path.value.value.replace( - selector, + selectorRegex, `${replacementSelectorPrefix}${replacementSelector}`, ), ),