-
Notifications
You must be signed in to change notification settings - Fork 65
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: uploaded svg icon not showing #3179
Conversation
Will ask API Key to test solution for |
🤖 Pull request artifacts
|
…elected); only apply SVG shapes fill if color exist
@Arukuen Issue has been fixed on the three blocks affected. However, there's one remaining issue for Map block only:
|
@andeng1106 Since the SVG is serialized for map block, the To address this, we can advise affected users to use the "Attempt Block Recovery" feature, which successfully reformats the URL to match the current build and resolves the block error. However, I would like ask for suggestion if there is a better approach. |
@Arukuen since we are encountering a block error that can be recovered, we'll need to add some deprecation code to handle migration of the icon. The expected behavior is for the map block not to encounter an error upon upgrading to this new build |
…elected); only apply SVG shapes fill if color exist
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.
It's great that deprecation is already handled, but it's also a good idea to further separate our deprecated code so it doesn't mingle with our up-to-date functionality. Currently, our deprecated code is located inside the util.js
code:
export const getIconOptions = ( attributes, isDeprecated ) => {
// ...
if ( isDeprecated ) {
// ...
I recommend reverting back to the original, then create a function specific for the needs of the deprecation inside src/block/map/deprecated.js
that uses the original getIconOptions
instead. This way, all our deprecated code stays out of our main code.
// file: src/block/map/deprecated.js
import { getIconOptions } from './utils'
const getIconOptions_3_13_0 = attributes => {
const newAttributes = { ...attributes }
// Do things required for the deprecation...
return getIconOptions( newAttributes )
}
addFilter( 'stackable.map.util.applySVGAttributes', 'stackable/3.13.0', ( output, attributes, props ) => {
if ( semverCompare( props.version, '<', '3.13.0' ) ) {
return getIconOptions_3_13_0( attributes )
}
return output
} )
src/block/map/save.js
Outdated
data-icon-options={ JSON.stringify( getIconOptions( attributes ) ) } | ||
data-icon-options={ JSON.stringify( | ||
applyFilters( | ||
'stackable.map.util.applySVGAttributes', |
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 recommend changing the name of this filter because if you look at where this filter is being used, it's not related to util.applySVGAttributes
. I feel like stackable.map.icon-options
makes more sense here:
'stackable.map.util.applySVGAttributes', | |
'stackable.map.icon-options', |
Also change the corresponding code that uses this filter
fixes #3103
Details of the issue and the solution: https://www.notion.so/SVG-icon-only-shows-up-on-some-blocks-with-icon-3103-94b9c7925d1f4eaba8ebb2752f4b1660?pvs=4
TLDR: The SVG that can be uploaded by the users might have inline style which takes precedence specially since this can be applied to the lowest level which is the
<path>
element. This PR fixes the issue by applying thefill
directly to<path>
to have higher precedence.