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] conflicts with Bootstrap #19463

Closed
2 tasks done
cadrimiranda opened this issue Jan 29, 2020 · 28 comments · Fixed by #19495 or #28674
Closed
2 tasks done

[TextField] conflicts with Bootstrap #19463

cadrimiranda opened this issue Jan 29, 2020 · 28 comments · Fixed by #19495 or #28674
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@cadrimiranda
Copy link
Contributor

cadrimiranda commented Jan 29, 2020

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When i use Bootstrap and MaterialUI, the Textfield with outlined variant and label with shrink props enter in conflicts with label style and the input show incorrect width of label inside the fieldset .

image

Expected Behavior 🤔

I want to use Bootstrap with MaterialUI in my project. In older versions, this does not happen (4.8.3 and under don't happen).

Steps to Reproduce 🕹

https://codesandbox.io/s/winter-meadow-219i9?fontsize=14&hidenavigation=1&theme=dark

Steps:

  1. Install Material UI core and style
  2. Install bootstrap
  3. Import bootstrap css in index.jsx
  4. Render the Textfield component

Context 🔦

My project design uses MaterialUI Components and Bootstrap and at the moment I can't remove the bootstrap or redesign my app to remove Material UI.

Your Environment 🌎

Tech Version
Material-UI v4.9.0
React v16.12.0
Browser Chrome v79.0.3945.130 and Brave Version 1.2.43 Chromium: 79.0.3945.130
TypeScript x
etc. x
@homyden
Copy link

homyden commented Jan 29, 2020

The problem appears not only with bootstrap.
When I use sanitize.css in project, I have the same issue.

@cadrimiranda
Copy link
Contributor Author

The problem appears not only with bootstrap.
When I use sanitize.css in project, I have the same issue.

Please, make a example in codesandbox too

@homyden
Copy link

homyden commented Jan 29, 2020

The problem appears not only with bootstrap.
When I use sanitize.css in project, I have the same issue.

Please, make a example in codesandbox too

https://codesandbox.io/s/angry-sun-2ii0r

@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Jan 29, 2020
@grant-davidson
Copy link

This can be fixed by adding this to your css:

legend {
width: auto
}

https://codesandbox.io/s/lucid-dewdney-frre4

@homyden
Copy link

homyden commented Jan 30, 2020

This can be fixed by adding this to your css:

legend {
width: auto
}

https://codesandbox.io/s/lucid-dewdney-frre4

replace label to "oooooo"

@cadrimiranda
Copy link
Contributor Author

cadrimiranda commented Jan 30, 2020

This can be fixed by adding this to your css:

legend {
width: auto
}

https://codesandbox.io/s/lucid-dewdney-frre4

This can solve, but with the label in uppercase this doesn't work. This is my case, take a look:

image

image

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work priority: important This change can make a difference labels Jan 30, 2020
@oliviertassinari
Copy link
Member

While this is an important issue to take care of to enable progressive migration from Bootstrap to Material-UI, I'm wondering.

What are the use cases for using Material-UI with Bootstrap outside legacy considerations? :)

@cadrimiranda
Copy link
Contributor Author

While this is an important issue to take care of to enable progressive migration from Bootstrap to Material-UI, I'm wondering.

What are the use cases for using Material-UI with Bootstrap outside legacy considerations? :)

We are developing a system with a deadline we cant go back and refact our code. The material part (Textfield and Grid) is minor than bootstrap (system grid)(and we have a lot of forms). I guess i will refactor input component to imitation of materialUI textfield haha

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 30, 2020

@cadrimiranda in this context, you can either revert to the previous release of Material-UI until we release a patch, wait for a patch, or go ahead with proposing a pull request to patch that we will release later this week.

However, it doesn't answer the question regarding the motivation for using both :).

@cadrimiranda
Copy link
Contributor Author

@oliviertassinari this can answer:

We are developing a system with a deadline we cant go back and refact our code.

In addition, in the initial phase of the project, we only used the bootstrap and the user interface / UX design left the organization and come another with the idea of ​​using Material Design and he proposed a new design. We liked it a lot and we are now using.

@homyden
Copy link

homyden commented Jan 30, 2020

Issue appears with another css libraries.

sanitize.css

sanitize

normilize.css

normalize

@Eplumecocq
Copy link

@homyden I'm facing the same issue with normilize.css.
Removing it seems to fix the problem for me, but this is definitely not the best solution.

@cadrimiranda
Copy link
Contributor Author

Thanks @homyden to find another use cases. Tonight i guess i'll fork the repository and try to fix this ...

@homyden
Copy link

homyden commented Jan 30, 2020

Thanks @homyden to find another use cases. Tonight i guess i'll fork the repository and try to fix this ...

You are welcome! =)

In version 4.8.3, textfield had a bug related to the label in the outline variant. If you use texfield in tabs for example. It has been fixed in this commit. And then changed transitions.

So, need to find out how another css libraries affect these changes

Sorry for my broken English =)

@oliviertassinari oliviertassinari removed the priority: important This change can make a difference label Jan 30, 2020
@oliviertassinari
Copy link
Member

normilize.css

It's a duplicate of #19386.

sanitize.css

It was fixed in #19389.

bootstrap

@grant-davidson has shared a solution. So I would suggest the following:

diff --git a/packages/material-ui/src/OutlinedInput/NotchedOutline.js b/packages/material-ui/src/OutlinedInput/NotchedOutline.js
index 9a339d0c9..1b474382d 100644
--- a/packages/material-ui/src/OutlinedInput/NotchedOutline.js
+++ b/packages/material-ui/src/OutlinedInput/NotchedOutline.js
@@ -34,7 +34,8 @@ export const styles = theme => {
     },
     /* Styles applied to the legend element. */
     legendLabelled: {
-      display: 'block',
+      display: 'block', // Fix conflict with normalize.css and sanitize.css
+      width: 'auto', // Fix conflict with bootstrap
       textAlign: 'left',
       padding: 0,
       height: 11, // sync with `lineHeight` in `legend` styles

@cadrimiranda Do you want to submit a pull request? :)

@oliviertassinari oliviertassinari added the good first issue Great for first contributions. Enable to learn the contribution process. label Jan 30, 2020
@cadrimiranda
Copy link
Contributor Author

@oliviertassinari i'll, thanks.

@adrijshikhar
Copy link

in bootstrap 5, doing this worked

legend {
  float: unset;
}

let me know if it works for you

@oliviertassinari
Copy link
Member

@adrijshikhar Do you see it displayed like this with Bootstrap v5?

Screenshot 2021-05-10 at 17 02 55

@adrijshikhar
Copy link

@adrijshikhar Do you see it displayed like this with Bootstrap v5?

Screenshot 2021-05-10 at 17 02 55

Yes

@oliviertassinari
Copy link
Member

oliviertassinari commented May 11, 2021

@adrijshikhar Ok, no objection to fix it in the NotchedOutlined directly, but I'm not sure we should care a lot either.

diff --git a/packages/material-ui/src/OutlinedInput/NotchedOutline.js b/packages/material-ui/src/OutlinedInput/NotchedOutline.js
index c690dedc37..50d2ee71d1 100644
--- a/packages/material-ui/src/OutlinedInput/NotchedOutline.js
+++ b/packages/material-ui/src/OutlinedInput/NotchedOutline.js
@@ -20,6 +20,7 @@ const NotchedOutlineRoot = experimentalStyled('fieldset')({
 });

 const NotchedOutlineLegend = experimentalStyled('legend')(({ styleProps, theme }) => ({
+  float: 'unset', // Fix conflict with bootstrap
   ...(styleProps.label === undefined && {
     padding: 0,
     lineHeight: '11px', // sync with `height` in `legend` styles
@@ -29,8 +30,8 @@ const NotchedOutlineLegend = experimentalStyled('legend')(({ styleProps, theme }
     }),
   }),
   ...(styleProps.label !== undefined && {
-    display: 'block',
-    width: 'auto',
+    display: 'block', // Fix conflict with normalize.css and sanitize.css
+    width: 'auto', // Fix conflict with bootstrap
     padding: 0,
     height: 11, // sync with `lineHeight` in `legend` styles
     fontSize: '0.75em',

@oliviertassinari oliviertassinari changed the title Textfield conflicts with Bootstrap [TextField] conflicts with Bootstrap May 11, 2021
@superior57
Copy link

the problem is same for me too.
Is there any solution?

@oliviertassinari
Copy link
Member

@talentedexpert0057 If you are seeing this issue #19463 (comment) feel free to submit a PR with the fix proposed.

@kuntal-ghosh
Copy link

kuntal-ghosh commented Jun 22, 2021

@adrijshikhar Do you see it displayed like this with Bootstrap v5?
Screenshot 2021-05-10 at 17 02 55

Yes

I am watching this issue in my codebase. how to solve this in my codebase? thank you.

@ciradu2204
Copy link

Hi, I am working on it

@mnajdova mnajdova added OCD21 and removed good first issue Great for first contributions. Enable to learn the contribution process. labels Jun 30, 2021
@oliviertassinari oliviertassinari added the ready to take Help wanted. Guidance available. There is a high chance the change will be accepted label Jul 16, 2021
@mnajdova mnajdova added good first issue Great for first contributions. Enable to learn the contribution process. and removed ready to take Help wanted. Guidance available. There is a high chance the change will be accepted OCD21 labels Aug 24, 2021
@ChrisClaude
Copy link
Contributor

ChrisClaude commented Sep 28, 2021

Hi, I am working on this issue.

@abdulmunimx63
Copy link

@adrijshikhar Do you see it displayed like this with Bootstrap v5?
Screenshot 2021-05-10 at 17 02 55

Yes

I am watching this issue in my codebase. how to solve this in my codebase? thank you.

Use the following property:
legend {
float: unset;
}

@aaarichter
Copy link
Contributor

@homyden the normalize.css screen you showed in #19463 (comment) actually happens with Safari 15 on mui.com

Bildschirmfoto 2022-03-12 um 22 02 17

Bildschirmfoto 2022-03-12 um 21 33 14

@michaldudak
Copy link
Member

This has been reported already in #31367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet