-
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
Add 'download' attr in anchor of file block #9346
Conversation
Regardless of the download button is shown or not, the link is also intended to perform the download, so the anchor must also have the 'download' attribute
// ensure download attribute is still set when fileName | ||
// is undefined. Using '' here as `true` still leaves | ||
// the attribute unset. | ||
download={ fileName || '' } |
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.
This make sense to me. Though changing the HTML output of any block means we need to provide a "deprecated version" to ensure old blocks saved with the old markup are "upgraded" when we open the post in the editor.
See https://wordpress.org/gutenberg/handbook/block-api/deprecated-blocks/
Also, make sure to check the unit tests, there's probably a fixture to update.
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.
I understand, however, I am web designer, and I'm not the knowledge to do this… I read the documentation but I don't know where to start.
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.
That's fine, I'll start to help when I have some time. The idea is that you'll have to copy the previous "save" function and "attributes" definition into a "deprecated version"
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.
Oh I noticed this change causes an error where the block become invalid after saving it and refreshing the page. Maybe there's a good reason for omitting the download attribute here (it's present in the download button). So I'm pinging @noisysocks for more info.
I hope support for the html5 download attribute gets added. Right now if you add "download" as an attribute in the code editor, it gets changed to download="" upon save, which keeps the download attribute from being properly interpreted, at least in the latest chrome browser. |
The PR lacks a related issue so I'm not completely sure about the the motivation, would be good to understand more about that. Also worth referencing the original issue for the file block - #5462. It didn't have a great deal of discussion, but it is mentioned a few times about the link being an actual link. The user can also still download the file by right-clicking if needed. Worth noting this other related PR (though it was only merged after this one was created), we only support download attributes that are true or undefined: |
Description
Regardless of the download button is shown or not, the link is also intended to perform the download, so the anchor must also have the 'download' attribute
How has this been tested?
Screenshots
Types of changes
Checklist: