Why ant design Drawer not showing close icon? - reactjs

This piece of code not showing any close icon in the ant design Drawer.
<Drawer
title="Job ID: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
placement="right"
closable={false}
onClose={onJobDetailsDrawerClose}
visible={jobDetailsDrawervisible}
width="75%"
closeIcon={<CloseOutlined />}
>
But the drawer API showed this:
Any idea why the Drawer not showing up any close icon?

Appears the close icon is hidden when you specify
closable={false}
Drawer API - closable
Whether a close (x) button is visible on top right of the Drawer
dialog or not.
With this prop set to false the drawer is toggleable externally.

Related

How to collapse Modal Material UI?

How to collapse Modal Material UI?
I'm using a Modal component mui and want to collapse the modal window? Tell me how to do it?
You mean close it?
Well, if that's the case this is how you do it.
<Dialog
onClose={() => setModal(false)}
>
<your divs here/>
</Dialog>

React Material Ui responsive drawer

I created a responsive navigation bar using the React material UI Appbar component.
If the screen size is large, it shows tabs in the navigation bar. If the screen size is medium or smaller, it uses material UI responsive drawer to show the navigation bar (home, about, etc) on the left side right below the navigation bar. How can I move the responsive material UI drawer to the right?
https://material-ui.com/components/drawers/#responsive-drawer
You can use the available anchor prop (read more here).
anchor='right'
<Drawer
container={container}
variant="temporary"
anchor='right'
open={mobileOpen}
onClose={handleDrawerToggle}
classes={{
paper: classes.drawerPaper,
}}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
>
{drawer}
</Drawer>
You can view the codesandbox here

How to open and close material navigation drawer in react

I followed this tutorial (Full code on github) and implemented the material drawer. Now I can't close the drawer or open it with something like a function. How can I do it?
also the drawer is not swapping.
How I can access to Drawer object inside my webpage (DOM)? And change it's state such open = false.
Sorry for my questions I'm very new to react.
<Drawer
variant="temporary"
anchor="right"
open={true}
>
<List>
<ListItem>
first text
</ListItem>
<ListItem>
b
</ListItem>
</List>
</Drawer>
I want to have a menu icon on top right of my page and when the user clicks on it a modal navigation drawer will display.
there are many examples here in material-ui docs of how to use Drawers. check this out

How can I set my button or icon color to be different when a user is at the certain component?

I have drawer buttons here and I want to change Icon colors when a user clicks to each button and stays there. Like, if users click 'Dashboard' and are staying in that components, the dashboard button color will be white so that the buttons are indicating where users are in the website
const drawer = (
<div>
<Button
variant='contained'
color='secondary'
onClick={handleToDashboard}
className={classes.customButton}
startIcon={<DashboardIcon style={{ color: 'black' }} />}
>
Dashboard
</Button>
<Button
variant='contained'
color='secondary'
onClick={handleToTest}
className={classes.customButton}
startIcon={<MapIcon />}
>
Map
</Button>
<Divider />
</div>
);
If this component is self-contained – that is, it doesn't load a new route whenever a user clicks a button, and instead remains on the existing page – you should maintain state (using setState if this is a class component or the useState hook for a functional component) that keeps track of whichever button was last pressed. You can update the state in your onClick callbacks and then make your color props conditional – for example:
<Button
variant='contained'
color={this.state.opened === 'map' ? 'white' : 'secondary'}
onClick={handleToTest}
className={classes.customButton}
startIcon={<MapIcon />}
>
If this is part of a navigation bar that handles routing between pages, then you should pass as a prop from whatever component is being displayed the value in the drawer that should be highlighted. So for instance, the Dashboard component could, if it has this drawer as a child, pass a prop telling the drawer that it should render the dashboard button color white.

Material-UI TextField inside Popper inside Dialog not working

Material-UI input elements like TextField are not working / can not get the focus if they are inside a Popper inside a Dialog.
<Dialog open={true}>
...
<Popper open={true} style={{zIndex: 1500}}>
...
<TextField />
...
</Popper>
...
</Dialog>
The zIndex value for the Popper element is necessary to display Popper in front of the Dialog element.
Simple codesandbox example: https://codesandbox.io/s/input-inside-popper-inside-dialog-not-working-9y7rg
You can use the disableEnforceFocus property on Dialog (inherited from Modal) to fix this.
<Dialog open={true} disableEnforceFocus>
<SimplePopper />
</Dialog>
Related answer: CKEditor 4 having problem when used in Material UI dialog

Resources