-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Mobile - Columns block - Fix transforming into a Group block crash #54035
Changes from all commits
f204e13
1ae7d9f
cc5efa9
28ee737
7069a35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -111,10 +111,10 @@ function ColumnEdit( { | |||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const renderAppender = useCallback( () => { | ||||||||||||||||||||||||||
const { width: columnWidth } = contentStyle[ clientId ]; | ||||||||||||||||||||||||||
const isFullWidth = columnWidth === screenWidth; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if ( isSelected ) { | ||||||||||||||||||||||||||
const { width: columnWidth } = contentStyle[ clientId ] || {}; | ||||||||||||||||||||||||||
const isFullWidth = columnWidth === screenWidth; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||
<View | ||||||||||||||||||||||||||
style={ [ | ||||||||||||||||||||||||||
|
@@ -133,7 +133,7 @@ function ColumnEdit( { | |||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
return null; | ||||||||||||||||||||||||||
}, [ contentStyle[ clientId ], screenWidth, isSelected, hasChildren ] ); | ||||||||||||||||||||||||||
}, [ contentStyle, clientId, screenWidth, isSelected, hasChildren ] ); | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value passed as gutenberg/packages/block-library/src/columns/edit.native.js Lines 147 to 157 in 1ae7d9f
Hence, using this new dependency list won't produce extra renders. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! Since it's still a dependency I left it to also avoid the ESLint warning, although it can be disabled it's best to leave it. |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if ( ! isSelected && ! hasChildren ) { | ||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,4 +204,8 @@ module.exports = { | |
}, | ||
picker: {}, | ||
pickerPointer: {}, | ||
columnsContainer: { | ||
marginLeft: 16, | ||
minWidth: 32, | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value passed as
contentStyle
iscontentWidths
, which is calculated in:gutenberg/packages/block-library/src/columns/edit.native.js
Lines 147 to 157 in 1ae7d9f
I checked the parameters passed in
getContentWidths
when transforming the block to a Group block, and noticed thatcolumnCount
is 0 in the first render after the transformation. In the second render, the column count is set to back the proper value and populatescontentWidths
with the expected data. Seems that upon transformation there's an initial state that doesn't have the columns parameter ready. That said, this approach makes sense and will definitely address the crash.