Skip to content

Put card list grid items in rows#122

Open
adebroux wants to merge 3 commits into
mainfrom
bugfix/grid-flickering
Open

Put card list grid items in rows#122
adebroux wants to merge 3 commits into
mainfrom
bugfix/grid-flickering

Conversation

@adebroux

@adebroux adebroux commented Jun 16, 2023

Copy link
Copy Markdown
Contributor

Problem

Card lists set to grid layout in responsive apps would have their height automatically collapse when they were selected in the editor.

https://trello.com/1/cards/645d32b21deee39c9c1d0441/attachments/645d35fac46e4d60cda83fb2/download/screencast_2023-05-11_22-35-32.mp4

Solution

Give the grid layout some structure, like we do with the masonry layout. Instead of just having a list of items, create rows for those items.

Additional Notes

There's still a problem where when you change the screen size or resize the component, the height of the items changes, but the bounding box for the card list component doesn't update until you de-select and re-select the component. This is a pre-existing issue with the card list in masonry layout, as well as the image list.
There's also a pre-existing issue with the card list in multi-column grid layout where it will flicker between showing 1 and 2 columns. We have a card for this already in the backlog.

@adebroux adebroux requested a review from a team June 16, 2023 22:07
@adebroux adebroux self-assigned this Jun 16, 2023
@adebroux

Copy link
Copy Markdown
Contributor Author

@michael-adalo michael-adalo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 nitpicks, 1 change (just minor related to React key attributes), otherwise lookin' good!
🙌

Comment thread src/CardList/index.js Outdated
Comment on lines +69 to +71
let columnCount = this.getColumnCount()
let count = Math.ceil(items.length / columnCount)
let rows = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: it should be possible to declare each of these as const, including rows.

Comment thread src/CardList/index.js Outdated
{rows.map((row, i) => (
<View key={i} style={styles.row}>
{row.map((itm) => (
<View style={columnWidth}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this <View> also have a key attribute as it's directly within the .map()? Looking at the previous code, I see renderCell() includes a key attribute that probably isn't effective anymore.

Comment thread src/CardList/index.js Outdated
let { fullWidth } = this.state
let width = fullWidth / columnCount - 8
const rows = this.getRows(items)
const columnWidth = { width: `${100 / columnCount}%` }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: would it be worth calling this something like cellContainerStyles, or something similar, since the object could potentially contain any number of styles?
Alternatively, setting it directly on the <View> would also be fine.

Comment thread src/CardList/index.js
editor,
} = this.props

let mediaPosition = media && media.position

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

image

@adebroux adebroux requested a review from michael-adalo June 20, 2023 14:31

@michael-adalo michael-adalo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants