Skip to content

Commit 3493b1c

Browse files
JessChowdhurykendelljoseph
authored andcommitted
fix: checks for localization to prevent publish button breaking (#10844)
This [PR](#9438) introduced a bug with the publish button, an error was being thrown when localization is false. Updated the logic breaking the publish button to safely check whether localization exists.
1 parent 2234c59 commit 3493b1c

File tree

1 file changed

+4
-3
lines changed
  • packages/ui/src/elements/PublishButton

1 file changed

+4
-3
lines changed

Diff for: packages/ui/src/elements/PublishButton/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const PublishButton: React.FC<{ label?: string }> = ({ label: labelProp }
166166
)
167167

168168
const publishAll =
169-
localization && localization.defaultLocalePublishOption !== 'active' ? true : false
169+
!localization || (localization && localization.defaultLocalePublishOption !== 'active')
170170

171171
const activeLocale =
172172
localization &&
@@ -175,9 +175,10 @@ export const PublishButton: React.FC<{ label?: string }> = ({ label: labelProp }
175175
)
176176

177177
const activeLocaleLabel =
178-
typeof activeLocale.label === 'string'
178+
activeLocale &&
179+
(typeof activeLocale.label === 'string'
179180
? activeLocale.label
180-
: (activeLocale.label?.[localeCode] ?? undefined)
181+
: (activeLocale.label?.[localeCode] ?? undefined))
181182

182183
const defaultPublish = publishAll ? publish : () => publishSpecificLocale(activeLocale.code)
183184
const defaultLabel = publishAll ? label : t('version:publishIn', { locale: activeLocaleLabel })

0 commit comments

Comments
 (0)