Blue dot appearing to left of user list - javascript

I have this render function:
render() {
const {classes} = this.props
return (
<Paper className={classes.root} elevation={4}>
<Typography type="title" className={classes.title}>
All Users
</Typography>
<List dense>
{this.state.users.map((item, i) => {
const photoUrl = item._id
? `/api/users/photo/${item._id}?${new Date().getTime()}`
: '/api/users/defaultphoto'
return <Link to={"/user/" + item._id} key={i}>
<ListItem button>
<ListItemAvatar>
<Avatar src={photoUrl} className={classes.bigAvatar}/>
</ListItemAvatar>
<ListItemText primary={item.name}/>
<ListItemSecondaryAction>
<IconButton>
<ArrowForward/>
</IconButton>
</ListItemSecondaryAction>
</ListItem>
</Link>
})
}
</List>
</Paper>
)
}
}
When I Initially load the page the below blue dot appears to the left of each user:
If I then click a link to another page and then the browser back arrow to return to the Users page the user list appears without the blue dot:
I would prefer if the blue dot never appears. How do I do this?

I faced the same problem today using ListItem component from react material ui v4.6.0.
The default list style type value of disc will be displayed if "ListItemSecondaryAction" component is used as the last child of "ListItem" component.
According to the React Material UI Docs, the value of ContainerComponent prop will be set to 'li' when ListItemSecondaryAction is used as the last child.
Changing the value of ContainerComponent prop to other elementType such as 'div' fixed the issue.
<ListItem button ContainerComponent="div">
<ListItemAvatar>
<Avatar src={photoUrl} className={classes.bigAvatar} />
</ListItemAvatar>
<ListItemText primary={item.name} />
<ListItemSecondaryAction>
<IconButton>
<ArrowForward />
</IconButton>
</ListItemSecondaryAction>
</ListItem>

I assume somewhere in the nested components you have a li of some sort.
The dots are from html list bullet points and can be removed by adding the following css:
ul {
list-style-type: none !important;
}
If the component is a part of the Material-UI library, you might need to add !important

Related

Material UI List Item Text: Primary Text Overflow

Sorry if this has been asked, I looked and couldn't find the answer!
I have a Material UI listview that has a set width (it's in a sidebar). I am trying to render the titles of some options, and the Primary text of ListItemText is wrapping past its container. Why is it not simply extending the container's height and going multi-line?
Thanks so much in advance!
return (
<ListItem
key={network._id}
selected={user.network && user.network._id === network._id}
>
<ListItemText
primary={network.name}
sx={{ maxWidth: '100%' }}
/>
<IconButton>
<DoubleArrowIcon />
</IconButton>
</ListItem>
);
All,
If you have my problem, here is what worked for me:
<ListItemText
primary={tooLongTitle}
primaryTypographyProps={{ style: { whiteSpace: "normal" } }} />
Credit:
multiline with <ListItemText>

No empty spaces? React + MUI Grid

I'm using Material UI Grid to make an image grid and I'm trying to get rid of the empty spaces between some grid items. I've tried changing the alignitems and justify values of the container, but it didn't work.
See image.
return <Grid container alignItems="flex-start" justify="center" className="img-container" spacing={2}>
{/* All images */}
{docs && docs
.map(image => (
// In a grid item
<Grid className="img-item" item key={image.id} xs={12} md={6} lg={4}>
{/* all accounts */}
{docs2 && docs2
.filter((user) => image.userID === user.userID)
.map(user => (
<div key={image.id} className="div">
<img src={image.url} alt="uploaded pic" />
<Typography variant="subtitle1"> By {user.userName}
{/* Delete button only renders if currentUser.uid === image.userID*/}
{handleButton(image.userID) &&
<IconButton
color="secondary" aria-label="delete image"
onClick={() => handleDeleteImage(image.id,
image.userID, image.name)}
component="span" >
<DeleteForever />
</IconButton>}
</Typography>
</div>
))}
</Grid>
))}
</Grid>
}
The problem is the Grid container, Grid item takes the size of its content in that case its image, but the Grid container takes the size of the Larger Grid item in your case the first Grid item that's why the following Grids have spaces below.
In your case, dealing with list of images you should use GridList component not Grid.
Follow this link for more details about it https://material-ui.com/components/grid-list/

How to change the background color of a row in a react-admin component based on props?

I'm designing a react-admin table, and I want to determine a row's background color by the "active" source of the row - if it's true I want the row background color to be green, otherwise I want it to be red.
I tried material ui's "makeStyles" with no success (all of this stuff is new to me).
This is my table:
const myTable = (props) => {
return (
<List {...props} pagination={<PostPagination />}>
<Datagrid>
<NumberField source="id" />
<TextField source="name" />
<TextField source="category" />
<TextField source="platform" />
<NumberField source="major" />
<NumberField source="minor" />
<BooleanField source="active" label="active"/>
<DateField source="audit" />
<EditButton basePath="versions" />
<DeleteButton basePath="versions" />
</Datagrid>
</List>
)
}
Thank you very much for any help!
Good afternoon, i didn't really understand that you have strings here, but there are many different options for example:
<MyRow style={{background: (isActive ? 'red' : 'green')} />
<MyRow className={isActive ? classes.activeRow : null />
In the first variant, you do not need to do anything with the styles, and in the second you will have to create a style for example through makeStyles.
const useStyles = makeStyles((theme) => ({
activeRow:{
backgroundColor: theme.palette.primary.main
}
}));

Disable button from clicking the parent element

I am building a Material UI app. I have a card component and I need to make it clickable. But there is also a button on the top right corner which edits the card on click. The problem is, when I click on that button, it'll handle 2 actions:
the edit action called on the button itself
clicks the card
Here is a snippet of code:
<CardActionArea href={`/${item.name}`}>
<Card key={index}>
<CardHeader
action={
<Fab color="secondary" onClick={handleClick}>
<EditIcon color={"primary"} />
</Fab>
}
/>
<CardContent className={classes.cardContent}>
<Avatar className={classes.avatar} alt={item.name} src={item.avatar} />
<Typography variant="h6" color="textSecondary">
Card description
</Typography>
</CardContent>
</Card>
</CardActionArea>
How could I achieve that?
In the card component you create both functions you want to run when clicking the card and the inner button:
const onCardClick = () => {
// your code here
}
const onButtonClick = () => {
onCardClick()
// your code here
}
In Card.jsx when rendering the button inside the card add the onButtonClick function
<MyButton onClick={onButtonClick}
then in your button component, you give it an onClick prop:
const MyButton = (props) => {
<Button onClick={prop.onClick}>title</Button>
}

Render component inside Tabs after .map function return

When I try to render TabPane inside a .map function I have the following issue: my component (DepartmentView) is rendered just for the first TabPane, for the next TabPane content is empty.
I am using ANT Design library.
My question is how can I render DepartmentView for each TabPane from the .map function?
<Tabs tabPosition="left" className="tab-view-page">
{
data.map((item) => (
<TabPane
tab={(
<CustomTabTitle
title={item.name}
subtitle=""
/>
)}
key={item.id}
>
<DepartmentView data={item} />
</TabPane>
))
}
</Tabs>
DepartmentView component:
<div className="main-section">
<div className="horizontal-tabs-container">
<Tabs className="horizontal-tabs-profile">
<TabPane tab={<FormattedHTMLMessage id="layout.tabs.overview" />} key="overview">
Here will be overview page
</TabPane>
<TabPane tab={<FormattedHTMLMessage id="layout.tabs.staff" />} key="staff">
<Employees />
</TabPane>
<TabPane tab={<FormattedHTMLMessage id="layout.tabs.settings" />} key="settings">
<Settings />
</TabPane>
</Tabs>
</div>
</div>
Please, check that you've imported antd css.
import "antd/dist/antd.css";
I don't see any syntax errors. Maybe you could check that the data array is greater than 1 in length and that each item object has all required keys.

Categories

Resources