-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix: File Block is crashing as soon as a file is selected #10323
Conversation
You could argue that the deprecations are not working here, but it's important to note that the wrong format prop is being set on diff --git a/packages/block-library/src/file/edit.js b/packages/block-library/src/file/edit.js
index 49b57c922..310468dea 100644
--- a/packages/block-library/src/file/edit.js
+++ b/packages/block-library/src/file/edit.js
@@ -191,7 +191,6 @@ class FileEdit extends Component {
tagName="div" // must be block-level or else cursor disappears
format="string"
value={ fileName }
- multiline="false"
placeholder={ __( 'Write file name…' ) }
keepPlaceholderOnFocus
formattingControls={ [] } // disable controls
@@ -202,12 +201,12 @@ class FileEdit extends Component {
{ /* Using RichText here instead of PlainText so that it can be styled like a button */ }
<RichText
tagName="div" // must be block-level or else cursor disappears
+ format="string"
className={ `${ className }__button` }
value={ downloadButtonText }
formattingControls={ [] } // disable controls
placeholder={ __( 'Add text…' ) }
keepPlaceholderOnFocus
- multiline="false"
onChange={ ( text ) => setAttributes( { downloadButtonText: text } ) }
/>
</div> |
8c281e2
to
ce546c3
Compare
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.
Looks good!
Thank you for the review and for the help in getting this PR done @iseulde. |
Thanks for the fixes to both.
|
Description
The file block was not updated to use the new RichText content structure and its old implementation had inconsistencies (string in the attributes, and not a string in one of the RichText).
So the file block was crashing as soon as a file was selected.
This PR updates file block to use the new RichText format.
Props to @iseulde for the help debugging this problem.
How has this been tested
Add a file block select some file, verify it is possible to change both file name and button text without problems. Save the post and verify the block appears correctly on the frontend.