Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Fix crash related to accessing undefined value in TextColorEdit #55664

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading