Skip to content

Commit

Permalink
[RNMobile] Fix crash related to accessing undefined value in `TextCol…
Browse files Browse the repository at this point in the history
…orEdit` (#55664)

* Guard `hasColorsToChoose` against potential `colors` undefined value

* Avoid returning undefined in `useMobileGlobalStylesColors`

* Update `react-native-editor` changelog
  • Loading branch information
fluiddot authored and cbravobernal committed Nov 14, 2023
1 parent 84500fc commit ac0bc76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getPxFromCssUnit,
useSettings,
useMultipleOriginColorsAndGradients,
SETTINGS_DEFAULTS,
} from '@wordpress/block-editor';

export const BLOCK_STYLE_ATTRIBUTES = [
Expand Down Expand Up @@ -355,13 +356,17 @@ export function useMobileGlobalStylesColors( type = 'colors' ) {
[]
);
// Default editor colors/gradients if it's not a block-based theme.
const colorPalette =
const defaultPaletteSetting =
type === 'colors' ? 'color.palette' : 'color.gradients';
const [ editorDefaultPalette ] = useSettings( colorPalette );
const [ defaultPaletteValue ] = useSettings( defaultPaletteSetting );
// In edge cases, the default palette might be undefined. To avoid
// exceptions across the editor in that case, we explicitly return
// the default editor colors.
const defaultPalette = defaultPaletteValue ?? SETTINGS_DEFAULTS.colors;

return availableThemeColors.length >= 1
? availableThemeColors
: editorDefaultPalette;
: defaultPalette;
}

export function getColorsAndGradients(
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For each user feature we should also add a importance categorization label to i

## Unreleased
- [*] Fix error when pasting deeply nested structure content [#55613]
- [*] Fix crash related to accessing undefined value in `TextColorEdit` [#55664]

## 1.107.0
- [*] Social Icons: Fix visibility of inactive icons when used with block based themes in dark mode [#55398]
Expand Down

0 comments on commit ac0bc76

Please sign in to comment.