Skip to content

Commit 9047dca

Browse files
committed
fix: useTypographyAsPresets reactivity
1 parent 0d6e5fa commit 9047dca

File tree

2 files changed

+7
-7
lines changed
  • src
    • block-components/typography
    • plugins/global-settings/typography

2 files changed

+7
-7
lines changed

src/block-components/typography/edit.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ export const Controls = props => {
8181
const attributeName = getAttrNameFunction( attrNameTemplate )
8282
const text = getAttribute( 'text' )
8383
const [ debouncedText, setDebouncedText ] = useState( text )
84-
const { useTypographyAsPresets } = useSelect( select => {
85-
const _useTypographyAsPresets = select( 'stackable/global-preset-controls.custom' )?.getUseTypographyAsPresets() ?? false
86-
return { useTypographyAsPresets: { ..._useTypographyAsPresets } }
87-
}, [] )
84+
const useTypographyAsPresets = useSelect( select =>
85+
select( 'stackable/global-preset-controls.custom' )?.getUseTypographyAsPresets() ?? false
86+
)
8887

8988
useEffect( () => {
9089
if ( text !== debouncedText ) {

src/plugins/global-settings/typography/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
101101
const { allCustomPresets, useTypographyAsPresets } = useSelect( select => {
102102
const _customPresetControls = select( 'stackable/global-preset-controls.custom' )?.getCustomPresetControls() ?? {}
103103
const _useTypographyAsPresets = select( 'stackable/global-preset-controls.custom' )?.getUseTypographyAsPresets() ?? false
104-
return { allCustomPresets: { ..._customPresetControls }, useTypographyAsPresets: { ..._useTypographyAsPresets } }
104+
return { allCustomPresets: { ..._customPresetControls }, useTypographyAsPresets: _useTypographyAsPresets }
105105
}, [] )
106106

107107
const FONT_PAIRS = applyFilters( 'stackable.global-settings.typography.font-pairs.premium-font-pairs', FREE_FONT_PAIRS )
@@ -125,10 +125,11 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
125125
} )
126126
}, [] )
127127

128-
// When typography styles are changed, trigger our editor style generator to update.
129128
useEffect( () => {
129+
// When typography styles are changed, trigger our editor style generator to update.
130130
doAction( 'stackable.global-settings.typography.update-trigger', typographySettings, applySettingsTo )
131131

132+
// Update the custom presets when using typography as presets
132133
if ( useTypographyAsPresets ) {
133134
const fontSizePresets = TYPOGRAPHY_TAGS
134135
.filter( ( { presetSlug } ) => !! presetSlug )
@@ -171,7 +172,7 @@ addFilter( 'stackable.global-settings.inspector', 'stackable/global-typography',
171172

172173
dispatch( 'stackable/global-preset-controls.custom' ).updateCustomPresetControls( newSettings )
173174
}
174-
}, [ JSON.stringify( typographySettings ), applySettingsTo ] )
175+
}, [ JSON.stringify( typographySettings ), applySettingsTo, useTypographyAsPresets ] )
175176

176177
// Scroll to the selected font pair when Global Typography tab is toggled
177178
useEffect( () => {

0 commit comments

Comments
 (0)