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

[Masonry] Place items to the left when there are less objects than specified in the column prop #32873

Merged
merged 4 commits into from
May 26, 2022

Conversation

hbjORbj
Copy link
Member

@hbjORbj hbjORbj commented May 23, 2022

Closes #32696

Problem:

  • Having only 2 items inside Masonry while columns prop is set to a value greater than 2, e.g. 3 or 4, items are stretched across the masonry instead of being placed together at the left.

Solution:

p.s. Argos changes are expected

Sorry, something went wrong.

hbjORbj added 3 commits May 23, 2022 12:16

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@hbjORbj hbjORbj added the component: masonry This is the name of the generic UI component, not the React module! label May 23, 2022
@hbjORbj hbjORbj self-assigned this May 23, 2022
@hbjORbj hbjORbj added the bug 🐛 Something doesn't work label May 23, 2022
@mui-bot
Copy link

mui-bot commented May 23, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 3d15644

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a screenshot fixture for it, it's more reliable test for this type of scenarios.

@hbjORbj
Copy link
Member Author

hbjORbj commented May 26, 2022

@mnajdova I agree!

e.g.,
Screenshot 2022-05-26 at 10 49 47

@hbjORbj hbjORbj requested a review from mnajdova May 26, 2022 09:50
@hbjORbj hbjORbj merged commit eceee03 into mui:master May 26, 2022
@mbrookes mbrookes changed the title [Masonry] Place items to the left when there is less object than specified in column prop [Masonry] Place items to the left when there are less objects than specified in the column prop May 26, 2022
@jackshi0912
Copy link

This could have introduce a new problem where the ImageListItemBar is rendered next to the image.
Screenshot 2023-08-06 130726

Steps to reproduce go to https://mui.com/material-ui/react-image-list/#title-bar-below-image-masonry and remove all but 2 data points in the code.

import * as React from 'react';
import Box from '@mui/material/Box';
import ImageList from '@mui/material/ImageList';
import ImageListItem from '@mui/material/ImageListItem';
import ImageListItemBar from '@mui/material/ImageListItemBar';

export default function TitlebarBelowMasonryImageList() {
  return (
    <Box sx={{ width: 500, height: 450, overflowY: 'scroll' }}>
      <ImageList variant="masonry" cols={3} gap={8}>
        {itemData.map((item) => (
          <ImageListItem key={item.img}>
            <img
              src={`${item.img}?w=248&fit=crop&auto=format`}
              srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
              alt={item.title}
              loading="lazy"
            />
            <ImageListItemBar position="below" title={item.author} />
          </ImageListItem>
        ))}
      </ImageList>
    </Box>
  );
}

const itemData = [
  {
    img: 'https://images.unsplash.com/photo-1549388604-817d15aa0110',
    title: 'Bed',
    author: 'swabdesign',
  },
  {
    img: 'https://images.unsplash.com/photo-1525097487452-6278ff080c31',
    title: 'Books',
    author: 'Pavel Nekoranec',
  },
 
];

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: masonry This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Masonry] Place items to the left when there is less object than specified in column prop
4 participants