Bug: Add checks to Geomap StyleEditor (#42266)

This commit is contained in:
nikki-kiga 2021-11-25 02:57:21 -08:00 committed by GitHub
parent 1b26d4d88e
commit d0c9564e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View File

@ -108,7 +108,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
<InlineFieldRow> <InlineFieldRow>
<InlineField label={'Symbol'}> <InlineField label={'Symbol'}>
<ResourceDimensionEditor <ResourceDimensionEditor
value={value.symbol ?? defaultStyleConfig.symbol} value={value?.symbol ?? defaultStyleConfig.symbol}
context={context} context={context}
onChange={onSymbolChange} onChange={onSymbolChange}
item={ item={
@ -127,7 +127,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</InlineFieldRow> </InlineFieldRow>
<Field label={'Rotation angle'}> <Field label={'Rotation angle'}>
<ScalarDimensionEditor <ScalarDimensionEditor
value={value.rotation ?? defaultStyleConfig.rotation} value={value?.rotation ?? defaultStyleConfig.rotation}
context={context} context={context}
onChange={onRotationChange} onChange={onRotationChange}
item={ item={
@ -146,7 +146,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
<InlineField label="Color" labelWidth={10}> <InlineField label="Color" labelWidth={10}>
<InlineLabel width={4}> <InlineLabel width={4}>
<ColorPicker <ColorPicker
color={value.color?.fixed ?? defaultStyleConfig.color.fixed} color={value?.color?.fixed ?? defaultStyleConfig.color.fixed}
onChange={(v) => { onChange={(v) => {
onColorChange({ fixed: v }); onColorChange({ fixed: v });
}} }}
@ -157,7 +157,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
<InlineFieldRow> <InlineFieldRow>
<InlineField label="Opacity" labelWidth={10} grow> <InlineField label="Opacity" labelWidth={10} grow>
<SliderValueEditor <SliderValueEditor
value={value.opacity ?? defaultStyleConfig.opacity} value={value?.opacity ?? defaultStyleConfig.opacity}
context={context} context={context}
onChange={onOpacityChange} onChange={onOpacityChange}
item={ item={
@ -180,7 +180,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
<> <>
<Field label={'Size'}> <Field label={'Size'}>
<ScaleDimensionEditor <ScaleDimensionEditor
value={value.size ?? defaultStyleConfig.size} value={value?.size ?? defaultStyleConfig.size}
context={context} context={context}
onChange={onSizeChange} onChange={onSizeChange}
item={ item={
@ -195,7 +195,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</Field> </Field>
<Field label={'Symbol'}> <Field label={'Symbol'}>
<ResourceDimensionEditor <ResourceDimensionEditor
value={value.symbol ?? defaultStyleConfig.symbol} value={value?.symbol ?? defaultStyleConfig.symbol}
context={context} context={context}
onChange={onSymbolChange} onChange={onSymbolChange}
item={ item={
@ -213,7 +213,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</Field> </Field>
<Field label={'Color'}> <Field label={'Color'}>
<ColorDimensionEditor <ColorDimensionEditor
value={value.color ?? defaultStyleConfig.color} value={value?.color ?? defaultStyleConfig.color}
context={context} context={context}
onChange={onColorChange} onChange={onColorChange}
item={{} as any} item={{} as any}
@ -221,7 +221,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</Field> </Field>
<Field label={'Fill opacity'}> <Field label={'Fill opacity'}>
<SliderValueEditor <SliderValueEditor
value={value.opacity ?? defaultStyleConfig.opacity} value={value?.opacity ?? defaultStyleConfig.opacity}
context={context} context={context}
onChange={onOpacityChange} onChange={onOpacityChange}
item={ item={
@ -238,7 +238,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
{settings?.displayRotation && ( {settings?.displayRotation && (
<Field label={'Rotation angle'}> <Field label={'Rotation angle'}>
<ScalarDimensionEditor <ScalarDimensionEditor
value={value.rotation ?? defaultStyleConfig.rotation} value={value?.rotation ?? defaultStyleConfig.rotation}
context={context} context={context}
onChange={onRotationChange} onChange={onRotationChange}
item={ item={
@ -254,7 +254,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
)} )}
<Field label={'Text label'}> <Field label={'Text label'}>
<TextDimensionEditor <TextDimensionEditor
value={value.text ?? defaultTextConfig} value={value?.text ?? defaultTextConfig}
context={context} context={context}
onChange={onTextChange} onChange={onTextChange}
item={{} as any} item={{} as any}
@ -266,7 +266,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
<HorizontalGroup> <HorizontalGroup>
<Field label={'Font size'}> <Field label={'Font size'}>
<NumberValueEditor <NumberValueEditor
value={value.textConfig?.fontSize ?? defaultStyleConfig.textConfig.fontSize} value={value?.textConfig?.fontSize ?? defaultStyleConfig.textConfig.fontSize}
context={context} context={context}
onChange={onTextFontSizeChange} onChange={onTextFontSizeChange}
item={{} as any} item={{} as any}
@ -274,7 +274,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</Field> </Field>
<Field label={'X offset'}> <Field label={'X offset'}>
<NumberValueEditor <NumberValueEditor
value={value.textConfig?.offsetX ?? defaultStyleConfig.textConfig.offsetX} value={value?.textConfig?.offsetX ?? defaultStyleConfig.textConfig.offsetX}
context={context} context={context}
onChange={onTextOffsetXChange} onChange={onTextOffsetXChange}
item={{} as any} item={{} as any}
@ -282,7 +282,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</Field> </Field>
<Field label={'Y offset'}> <Field label={'Y offset'}>
<NumberValueEditor <NumberValueEditor
value={value.textConfig?.offsetY ?? defaultStyleConfig.textConfig.offsetY} value={value?.textConfig?.offsetY ?? defaultStyleConfig.textConfig.offsetY}
context={context} context={context}
onChange={onTextOffsetYChange} onChange={onTextOffsetYChange}
item={{} as any} item={{} as any}
@ -291,7 +291,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</HorizontalGroup> </HorizontalGroup>
<Field label={'Align'}> <Field label={'Align'}>
<RadioButtonGroup <RadioButtonGroup
value={value.textConfig?.textAlign ?? defaultStyleConfig.textConfig.textAlign} value={value?.textConfig?.textAlign ?? defaultStyleConfig.textConfig.textAlign}
onChange={onTextAlignChange} onChange={onTextAlignChange}
options={[ options={[
{ value: TextAlignment.Left, label: TextAlignment.Left }, { value: TextAlignment.Left, label: TextAlignment.Left },
@ -302,7 +302,7 @@ export const StyleEditor: FC<StandardEditorProps<StyleConfig, StyleEditorOptions
</Field> </Field>
<Field label={'Baseline'}> <Field label={'Baseline'}>
<RadioButtonGroup <RadioButtonGroup
value={value.textConfig?.textBaseline ?? defaultStyleConfig.textConfig.textBaseline} value={value?.textConfig?.textBaseline ?? defaultStyleConfig.textConfig.textBaseline}
onChange={onTextBaselineChange} onChange={onTextBaselineChange}
options={[ options={[
{ value: TextBaseline.Top, label: TextBaseline.Top }, { value: TextBaseline.Top, label: TextBaseline.Top },

View File

@ -5,7 +5,7 @@ import { defaultStyleConfig, StyleConfig, StyleConfigFields, StyleConfigState }
/** Indicate if the style wants to show text values */ /** Indicate if the style wants to show text values */
export function styleUsesText(config: StyleConfig): boolean { export function styleUsesText(config: StyleConfig): boolean {
const { text } = config; const text = config?.text;
if (!text) { if (!text) {
return false; return false;
} }