Skip to content

Commit

Permalink
Fix Google Translate zero width space issue
Browse files Browse the repository at this point in the history
  • Loading branch information
d3mp committed Jan 23, 2021
1 parent 528d3e5 commit baf6b73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/material-ui/src/FormHelperText/FormHelperText.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ const FormHelperText = React.forwardRef(function FormHelperText(props, ref) {
{...other}
>
{children === ' ' ? (
// notranslate needed while Google Translate will not fix zero width space issue
// eslint-disable-next-line react/no-danger
<span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
<span className="notranslate" dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
) : (
children
)}
Expand Down
10 changes: 8 additions & 2 deletions packages/material-ui/src/OutlinedInput/NotchedOutline.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ const NotchedOutline = React.forwardRef(function NotchedOutline(props, ref) {
>
{/* Use the nominal use case of the legend, avoid rendering artefacts. */}
{/* eslint-disable-next-line react/no-danger */}
{label ? <span>{label}</span> : <span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />}
{label ? (
<span>{label}</span>
) : (
// notranslate needed while Google Translate will not fix zero width space issue
<span className="notranslate" dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
)}
</legend>
</fieldset>
);
Expand Down Expand Up @@ -125,8 +130,9 @@ const NotchedOutline = React.forwardRef(function NotchedOutline(props, ref) {
}}
>
{/* Use the nominal use case of the legend, avoid rendering artefacts. */}
{/* notranslate needed while Google Translate will not fix zero width space issue */}
{/* eslint-disable-next-line react/no-danger */}
<span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
<span className="notranslate" dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
</legend>
</fieldset>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
>
{/* So the vertical align positioning algorithm kicks in. */}
{isEmpty(display) ? (
// notranslate needed while Google Translate will not fix zero width space issue
// eslint-disable-next-line react/no-danger
<span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
<span className="notranslate" dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
) : (
display
)}
Expand Down

0 comments on commit baf6b73

Please sign in to comment.