React - White screen displaying on the side with Internet Explorer - javascript

The app is working perfectly on every browser except for Internet Explorer 11.
IE Display
Look how there's a white screen that appears on the side of the map and it moves the buttons on the footer.
This is how it should display:
Mozilla Right Displaying
Why is this happening? This only happens in IE. Is there an issue with the flexboxs on IE?
Here is part of the code
const NoAuthFooter = props => {
const classes = useStyles();
const { classes: propClasses = {} } = props;
return (
<Toolbar className={clsx(classes.footbar, propClasses.root)}>
<div className={classes.company}>
<Typography variant="h6">
Hecho con <SvgHeartBlockyEmpty width="16" height="16" />
por Innovación
</Typography>
</div>
<div className={classes.actions}>
<div className={clsx(classes.buttonContainer, classes.rowContainer)}>
<LinkButton title="Más cerca de ti" to="/closer" />
</div>
<div className={classes.buttonContainer}>
<LinkButton
id="WebFooter_a_terms"
title="Términos"
to={{
pathname: ROUTE_NAMES.information,
aboutProps: {
subject: MENU.terms
}
}}
/>
</div>
<div className={classes.buttonContainer}>
<LinkButton
id="WebFooter_a_help"
title="Ayuda"
to={{
pathname: ROUTE_NAMES.information,
aboutProps: {
subject: MENU.help
}
}}
/>
</div>
</div>
</Toolbar>
);
};
const useStyles = makeStyles(theme => ({
footbar: {
position: 'relative',
display: 'flex',
width: '100%',
bottom: 0,
boxShadow: '0px 2px 10px -1px rgba(0,0,0,0.2)',
backgroundColor: '#FFFFFF'
},
company: {
flex: 1,
color: theme.palette.color.default,
'#media (max-width:600px)': {
display: 'none'
},
[theme.breakpoints.up('lg')]: {
flex: 2
}
},
companyText: {
display: 'inline',
fontSize: 12
},
actions: {
flex: 1,
display: 'flex',
justifyContent: 'flex-end',
'#media (max-width:600px)': {
flex: 1,
justifyContent: 'space-around'
}
},
buttonContainer: {
flex: 1,
justifyContent: 'center',
// * Responsive
[theme.breakpoints.up('sm')]: {
maxWidth: 160
}
},
rowContainer: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-start',
flex: 2
},
mobileHide: {
display: 'none',
[theme.breakpoints.up('md')]: {
display: 'block'
}
}
}));
Thanks for the help.

IE browser has below compatibility issues with flexbox.
IE 11 requires a unit to be added to the third argument, the flex-basis property see MSFT documentation
In IE10 and IE11, containers with display: flex and flex-direction: column will not properly calculate their flexed childrens' sizes if the container has min-height but no explicit height property.
IE 11 does not vertically align items correctly when min-height is used
In IE10 the default value for flex is 0 0 auto rather than 0 1 auto as defined in the latest spec.
Reference:
CSS Flexbox
I suggest you refer to the link below that may help to fix the issue.
Fixing Flexbox positioning for IE10 & IE11
If the issue persists then I suggest you post the sample code using only HTML and CSS. We will try to check and test it and try to provide suggestions for it.

Related

antd ProForm ProFormList component copyIcon creates row instead of copying the input text

<ProFormList
name={name}
initialValue={initialValue}
creatorButtonProps={{
creatorButtonText: '',
style: {
width: 22,
height: 22,
position: 'absolute',
top: 27,
right: -30,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
border: '1px solid #056DFA',
borderRadius: '100%',
},
}}
copyIconProps={{ tooltipText: 'დაკოპირება' }}
deleteIconProps={{ tooltipText: 'წაშლა' }}
creatorRecord={creatorRecord}
min={1}
>
{children}
</ProFormList>
I am using antd. And when clicking copy button which antd ProFormList contains it creates a new row instead copying the input string. Antd has the same exact problem on their website examples (https://procomponents.ant.design/en-US/components/dependency view the first code example)
Does anyone know how to fix this error. Thank you in advance.

Left space between two texts (Dynamic)

const Btn = () => {
const options = ['test1', 'test2', 'test3'];
return (
<div style={{ position: 'absolute', left: '8px', widht: 'auto', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', backgroundColor: '#006C84' }}>
{options.map(opt => (
<span style={{ paddingRight: '10px' }}>{opt}</span>)
)}
</div>
)
}
Above is my code and after the end of the text, there is some extra space are left. How to remove that space.
So you are giving paddingRight: 10px to the span, so at the end of the last child it's showing some space left.
There are two ways you can achive this
JS way
Css way
JS way
{options.map((opt,index) => (
<span style={{ paddingRight: options.length - 1 === index ? '10px' : "0px" }}>{opt}</span>)
)}
Css way
you need to change the inline style to explicit style for this, I would say this is the recommended way of giving css over inline style or may be you can create one style object for that.
<div className="parent">
{options.map(opt => (
<span style={{ paddingRight: '10px' }}>{opt}</span>)
)}
</div>
.parent{//parent css goes here}
.parent span:not(::last-of-type){padding-right: 10px}
const Btn = () => {
const options = ['test1', 'test2', 'test3'];
return (
<div style={{ position: 'absolute', left: '8px', widht: 'auto', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', backgroundColor: '#006C84', display: 'flex', gap: '10px' }}>
{options.map(opt => (
<span>{opt}</span>)
)}
</div>
)
}
use display: flex and gap inside the parent div style
https://codesandbox.io/s/keen-ganguly-kl4ys7?file=/src/App.js

responsive div height on conditional rendering?

I am working on a react project, where I want to conditionally render a div above an existing div that currently covers the screen with an image. I would like the existing div to reduce in height, by shrinking the size of the image, when the second div conditionally renders. The second div can have a varied height. ( e.g. list of items).
This is simplified version of what I have in my App so far:
function App() {
const [show, setShow] = useState(false);
return (
<div
style={{
border: "solid",
width: "100%",
maxHeight: "100vh"
}}
>
{show && (
<div>
<div style={{ height: "300px", backgroundColor: "red" }}></div>
<button
onClick={() => {
setShow(false);
}}
>
Close
</button>
</div>
)}
<div
style={{
display: "flex",
justifyContent: "center"
}}
>
<img
src="https://i.imgur.com/LiAUjYw.png"
alt="test"
style={{
maxWidth: "100%",
height: "auto"
}}
/>
</div>
<button onClick={() => setShow(true)}>SHow</button>
</div>
);
}
It initially looks like this: https://imgur.com/a/R0e74Xk
And on clicking the 'Show' button, it looks like this: https://imgur.com/a/Iy6osio
As you can see the bottom div gets shifted down, and goes over the container div.
I was wondering how I can make the div responsive enough to change its height when the other element is rendered.
I am fairly new to styling so any help on this would be greatly appreciated.
Thank you.
Here's one simple idea. See how the style is given to the divs like so:
<div
style={{
display: "flex",
justifyContent: "center"
}}
>
Note how the style has this weird {{ }} notation. That's because style accepts an object, and the object here is:
{
display: "flex",
justifyContent: "center"
}
You could take that object and save it as a variable somewhere, for example:
const styleWhenShow = {
display: "flex",
justifyContent: "center",
height: "100px"
}
const styleWhenNoShow = {
display: "flex",
justifyContent: "center",
height: "500px"
}
Since you already have your show state, now it's just a matter of replacing the style prop with:
style={show ? styleWhenShow : styleWhenNoShow}
In case you don't want to repeat some common styles between the show and noshow styles, you can also do something like:
const commonStyle = {
display: "flex",
justifyContent: "center"
}
const styleWhenShow = {
height: "100px"
}
const styleWhenNoShow = {
height: "500px"
}
And set the style prop like:
style={show ? { ...commonStyle, ...styleWhenShow } : { ...commonStyle, ...styleWhenNoShow }}

Position Material-UI Drawer component under Appbar

I'm creating a single-page application (Material-UI based) with an AppBar (+ ToolBar) and a Drawer. At the moment, the Drawer overlaps the AppBar and under no circumstances can I get the Drawer to move down, so it is basically positioned right under the AppBar.
I tried adding some padding, but this does not do anything. I'm using makeStyles for styling of most of the components, and I am wondering if it is even possible to position the Drawer below the AppBar.
Is there any way to position the drawer below the AppBar?
I have a lot of code, but the makeStyle function is simple:
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
},
title: {
flexGrow: 1,
},
toolbar: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: theme.spacing(0, 1),
...theme.mixins.toolbar,
},
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
drawer: {
paddingTop: 30
},
}));
and the main component (that includes the Drawer:
<div className={classes.root}>
<AppBar position="absolute" >
<Toolbar>
<Typography component="h1" variant="h6" noWrap className={classes.title}>
x
</Typography>
<Switch checked={isDarkTheme} onChange={handleThemeSwitch}/>
<WbIncandescentIcon />
</Toolbar>
</AppBar>
<ServiceDrawer className={classes.drawer}
onOperationSelected={onOperationSelect} serviceList={services} onDrawerOpen={onDrawerOpen} onDrawerClose={onDrawerClose}>
</ServiceDrawer>
<main className={classes.content}>
<div className={classes.toolbar} />
{selectedOperation && <Operation operation={selectedOperation}/>}
</main>
</div>
You need to set the variant of the Drawer to permanent so that it does not create an overlay over the current page, and put it inside the current app layout. Because the Drawer position is fixed, you also have to set the AppBar to fixed so they're on the same stacking context, and the z-index will be applied correctly, to put it in code:
<Drawer variant="permanent"
<AppBar position="fixed"
And finally the zIndex itself
appBar: {
zIndex: theme.zIndex.drawer + 1
},
Reference
https://v4.mui.com/components/drawers/#clipped-under-the-app-bar

justifyContent with createStyles in TypeScript

I have a toolbar where I am using 2 icons that appear on the left end. Currently, I am using this styling method:
const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
display: 'flex',
},
appBar: {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: drawerWidth,
},
drawer: {
width: drawerWidth,
flexShrink: 0,
},
drawerPaper: {
width: drawerWidth,
},
panelheaderRight: {
marginRight: 0,
right: 0,
},
toolbar: theme.mixins.toolbar,
content: {
flexGrow: 1,
// justifyContent: spaceBetween,
backgroundColor: theme.palette.background.default,
padding: theme.spacing(3),
},
}),
);
I want the icons to appear on the right end. If I add a separate css file with this, it works:
.toolbar-class{
justify-content:space-between;
}
but I want to use it inside the createStyles. There's no 'space-between' option in createStyles. This is how a portion of my component looks like:
<AppBar position="fixed" className={classes.appBar}>
<Toolbar className="toolbar-class">
<Typography variant="h6" noWrap>
Al
</Typography>
<div className="panelheaderRight">
<NotificationsIcon />
{/* <ExitToAppIcon onClick={() =>
<ExitToAppIcon onClick={logout}></ExitToAppIcon>
</div>
</Toolbar>
</AppBar>
Is there any way I can move the icons to the left using createStylesand without adding a separate css file?
Some notice points:
Change justify-content to justifyContent, and value as string.
No need to use createStyels for makeStyles
const useStyles = makeStyles((theme: Theme) => ({
toolBar: {
justifyContent: 'space-between'
},
...
...
<Toolbar className={classes.toolBar}>

Categories