Skip to content

Commit a252a80

Browse files
committed
fix: override allowReset instead
1 parent 029c41e commit a252a80

File tree

1 file changed

+15
-1
lines changed
  • src/components/typography-control

1 file changed

+15
-1
lines changed

src/components/typography-control/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import { Fragment, useMemo } from '@wordpress/element'
1919
import { i18n } from 'stackable'
2020

2121
const TypographyControl = props => {
22+
const {
23+
isAllowReset = undefined, // Optional prop
24+
} = props
25+
2226
// Compute the font size placeholder value.
2327
const placeholder = useMemo( () => {
2428
if ( typeof props.placeholder === 'function' ) {
@@ -29,13 +33,23 @@ const TypographyControl = props => {
2933
return props.fontSize || props.placeholder || getDefaultFontSize( props.htmlTag, true )
3034
}, [ props.htmlTag, props.fontSize ] )
3135

36+
// Allow overriding, or use our original condition
37+
const _allowReset = typeof isAllowReset !== undefined ? isAllowReset : (
38+
props.fontFamily ||
39+
props.fontSize || props.tabletFontSize || props.mobileFontSize ||
40+
props.fontWeight ||
41+
props.textTransform ||
42+
props.lineHeight || props.tabletLineHeight || props.mobileLineHeight ||
43+
props.letterSpacing || props.tabletLetterSpacing || props.mobileLetterSpacing
44+
)
45+
3246
return (
3347
<Fragment>
3448
<ButtonIconPopoverControl
3549
label={ props.label }
3650
popoverLabel={ props.popoverLabel }
3751
onReset={ props.onReset }
38-
allowReset={ props?.isAllowReset }
52+
allowReset={ _allowReset }
3953
resetPopoverTitle={ props.resetPopoverTitle }
4054
resetPopoverDescription={ props.resetPopoverDescription }
4155
className={ props.className }

0 commit comments

Comments
 (0)