@@ -13,6 +13,29 @@ import { NO_CUSTOM_VALUE, SELECTED_CLASS, ANIMATIONS, DEFAULT_SIZE } from './con
1313const STYLES_TAB_NAME = 'styling'
1414const ANIMATIONS_TAB_NAME = 'animations'
1515
16+ function buildThemeColors ( editorSettings ) {
17+ // This is a workaround for this Gutenberg bug:
18+ // https://github.com/WordPress/gutenberg/issues/64857
19+ //
20+ // When the user has defined custom colors the Gutenberg editorSettings.colors array
21+ // contains only that custom color and not the full set of theme colors.
22+ // However, the full set of theme colors is available under the
23+ // editorSettings.__experimentalFeatures.
24+ //
25+ // If we detect that the colors array is shorter than the combined
26+ // experimental theme + custom colors arrays, we use the experimental arrays.
27+ const canonicalThemeColors = [ ...editorSettings . colors ]
28+ const experimentalThemeColors = editorSettings ?. __experimentalFeatures ?. color ?. palette ?. theme || [ ]
29+ const experimentalCustomColors = editorSettings ?. __experimentalFeatures ?. color ?. palette ?. custom || [ ]
30+ const experimentalColors = [ ...experimentalThemeColors , ...experimentalCustomColors ]
31+
32+ if ( canonicalThemeColors . length >= experimentalColors . length ) {
33+ return canonicalThemeColors
34+ } else {
35+ return experimentalColors
36+ }
37+ }
38+
1639const SettingsTabPanel = ( { onSelect, onSizeChange, setColor, setAnimation, updateTransform, editorSettings, attributes } ) => {
1740 const [ customRotate , setCustomRotate ] = useState ( NO_CUSTOM_VALUE )
1841 const currentIconLayer = ( attributes ?. iconLayers || [ ] ) [ 0 ]
@@ -110,14 +133,16 @@ const SettingsTabPanel = ({ onSelect, onSizeChange, setColor, setAnimation, upda
110133 ] }
111134 >
112135 { ( tab ) => {
136+ const themeColors = buildThemeColors ( editorSettings )
137+
113138 if ( STYLES_TAB_NAME == tab . name )
114139 return (
115140 < div className = "fawp-icon-styling-tab-content-wrapper fawp-tab-content-wrapper" >
116141 < div className = "fawp-icon-styling-tab-content fawp-icon-styling-color fawp-tab-content" >
117142 < div className = "fawp-options-section-heading" > { __ ( 'Color' , 'font-awesome' ) } </ div >
118143 < div >
119144 < Colors
120- themeColors = { editorSettings . colors }
145+ themeColors = { themeColors }
121146 onChange = { setColor }
122147 attributes = { attributes }
123148 />
0 commit comments