diff --git a/.yarn/patches/@7rulnik-react-element-to-jsx-string-npm-15.0.1-e53b67c4b3.patch b/.yarn/patches/@7rulnik-react-element-to-jsx-string-npm-15.0.1-e53b67c4b3.patch new file mode 100644 index 000000000000..4c53827bc11d --- /dev/null +++ b/.yarn/patches/@7rulnik-react-element-to-jsx-string-npm-15.0.1-e53b67c4b3.patch @@ -0,0 +1,34 @@ +diff --git a/dist/cjs/index.js b/dist/cjs/index.js +index 6d1961830f978c0f3d90cc864003b0c50eb98f0d..9d48f1990ef440431e0e12ebf7560912893cd725 100644 +--- a/dist/cjs/index.js ++++ b/dist/cjs/index.js +@@ -373,11 +373,7 @@ var formatProp = (function (name, hasValue, value, hasDefaultValue, defaultValue + var attributeFormattedInline = ' '; + var attributeFormattedMultiline = "\n".concat(spacer(lvl + 1, tabStop)); + var isMultilineAttribute = formattedPropValue.includes('\n'); +- if (useBooleanShorthandSyntax && formattedPropValue === '{false}' && !hasDefaultValue) { +- // If a boolean is false and not different from it's default, we do not render the attribute +- attributeFormattedInline = ''; +- attributeFormattedMultiline = ''; +- } else if (useBooleanShorthandSyntax && formattedPropValue === '{true}') { ++ if (useBooleanShorthandSyntax && formattedPropValue === '{true}') { + attributeFormattedInline += "".concat(name); + attributeFormattedMultiline += "".concat(name); + } else { +diff --git a/dist/esm/index.js b/dist/esm/index.js +index 1c23d38bc15c76c6f9277c39b362f01e99e561ae..4e2de641a3ddb5851f7afa18c74d5a0f22d1c364 100644 +--- a/dist/esm/index.js ++++ b/dist/esm/index.js +@@ -347,11 +347,7 @@ var formatProp = (function (name, hasValue, value, hasDefaultValue, defaultValue + var attributeFormattedInline = ' '; + var attributeFormattedMultiline = "\n".concat(spacer(lvl + 1, tabStop)); + var isMultilineAttribute = formattedPropValue.includes('\n'); +- if (useBooleanShorthandSyntax && formattedPropValue === '{false}' && !hasDefaultValue) { +- // If a boolean is false and not different from it's default, we do not render the attribute +- attributeFormattedInline = ''; +- attributeFormattedMultiline = ''; +- } else if (useBooleanShorthandSyntax && formattedPropValue === '{true}') { ++ if (useBooleanShorthandSyntax && formattedPropValue === '{true}') { + attributeFormattedInline += "".concat(name); + attributeFormattedMultiline += "".concat(name); + } else { diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json index 741f83c6d7e7..d9f44fe45892 100644 --- a/code/renderers/react/package.json +++ b/code/renderers/react/package.json @@ -75,7 +75,7 @@ "expect-type": "^0.15.0", "html-tags": "^3.1.0", "prop-types": "^15.7.2", - "react-element-to-jsx-string": "npm:@7rulnik/react-element-to-jsx-string@15.0.1", + "react-element-to-jsx-string": "patch:react-element-to-jsx-string@npm%3A@7rulnik/react-element-to-jsx-string@15.0.1#~/.yarn/patches/@7rulnik-react-element-to-jsx-string-npm-15.0.1-e53b67c4b3.patch", "require-from-string": "^2.0.2", "ts-dedent": "^2.0.0", "type-fest": "^5.6.0" diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index be425ae2233b..8010177a9160 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -297,6 +297,18 @@ describe('renderJsx', () => { `); }); + + // Regression for #27127: react-element-to-jsx-string used to omit boolean + // props explicitly set to `false`. Patched via algolia/react-element-to-jsx-string#733 + // so a `false` prop is rendered while a `true` prop keeps the shorthand syntax. + it('should render boolean props set to false', () => { + expect(renderJsx(