Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextField] Outline has Inline Styles #13364

Closed
2 tasks done
tylervick opened this issue Oct 24, 2018 · 12 comments
Closed
2 tasks done

[TextField] Outline has Inline Styles #13364

tylervick opened this issue Oct 24, 2018 · 12 comments
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request v4.x

Comments

@tylervick
Copy link

Using the TextField component with the variant prop set to "outlined" will inline a padding-left and width inline style. This is difficult to accommodate for Content Security Policy.

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

All styles provided by material-ui should be inlined in the head tag which contains a CSP nonce

Current Behavior

When implementing TextField, the following HTML is output - note the style attributes

<fieldset aria-hidden="true" class="MuiNotchedOutline-root-174 MuiOutlinedInput-notchedOutline-151" style="padding-left: 8px;">
    <legend class="MuiNotchedOutline-legend-175" style="width: 38px;"></legend>
</fieldset>

Steps to Reproduce

Link: https://codesandbox.io/s/31prwv9j5q

  1. Implement TextField component
  2. add variant="outlined"
  3. Inspect the fieldset and input elements

Context

This makes implementing a good CSP difficult due to arbitrary inline styles

Your Environment

Tech Version
Material-UI v3.2.2
React v16.5.2
Browser Chrome 69
@oliviertassinari oliviertassinari added component: text field This is the name of the generic UI component, not the React module! new feature New feature or request labels Oct 24, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 24, 2018

@tylervick This is quite a strict security policy! There is a related issue on React side: facebook/react#5878. We could change the approach. I have no object for that. But we might also want to use svg over fieldset in #13297.

@oliviertassinari
Copy link
Member

@tylervick Could you tell me more about this requirement?

@AlexCppns
Copy link

Any update on this?

@oliviertassinari
Copy link
Member

I'm not sure we should fix this issue. We are using inline style at different locations in the code base.
cc @mui-org/core-contributors.

@oliviertassinari oliviertassinari added the waiting for 👍 Waiting for upvotes label Apr 1, 2019
@AlexCppns
Copy link

The issue I have in practice with this is a display bug when the TextField changes from hidden to displayed:

Screen Shot 2019-04-01 at 2 18 26 PM

It's a display bug that occurs even when I force the label to be sticky:

export const OutlinedTextField: React.FC<any> = ({ ...props }) => {
  const usedProps: any = {
    ...props,
    variant: "outlined"
  };
  return (
    <TextField
      {...usedProps}
      input={{ ...props.input }}
      InputLabelProps={{ shrink: true }}
    />
  );
};

@eps1lon
Copy link
Member

eps1lon commented Apr 1, 2019

I'm not familiar enough with inline styles and CSP. Is this just a concern for inputs or inline styles in general? I think it would require quite a bit of effort for our transition components to remove the inline styles.

@oliviertassinari
Copy link
Member

@AlexCppns This is a different issue. The best workaround is to change the key. It's basically the same root cause than: #15142.

@AlexCppns
Copy link

@octavioamu it works, thanks.

@octavioamu
Copy link
Contributor

I think you mean @oliviertassinari @AlexCppns :)

@AlexCppns
Copy link

ohh :p

@oliviertassinari oliviertassinari changed the title TextField Outline has Inline Styles [TextField] Outline has Inline Styles Nov 30, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 30, 2019

I'm closing as I don't think that we should stop ourselves to use inline style if it can enable better solutions.

Regrading the very case of the text field, #17680 will very likely remove this inline style.

See #19938 for the general issue with inline-style for CSP.

@oliviertassinari
Copy link
Member

This issue is solved in v5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request v4.x
Projects
None yet
Development

No branches or pull requests

5 participants