Skip to content

Commit

Permalink
fix: x axis title disappears when editing bar chart (#30821)
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianPendrak authored Nov 29, 2024
1 parent 14682b9 commit 97dde8c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export interface BaseControlConfig<
props: ControlPanelsContainerProps,
controlData: AnyDict,
) => boolean;
disableStash?: boolean;
hidden?:
| boolean
| ((props: ControlPanelsContainerProps, controlData: AnyDict) => boolean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isVertical(controls) : isHorizontal(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -90,6 +92,8 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isVertical(controls) : isHorizontal(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -104,6 +108,8 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -121,6 +127,8 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -138,6 +146,8 @@ function createAxisTitleControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Changing this control takes effect instantly'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -160,6 +170,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isVertical(controls) : isHorizontal(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -170,6 +182,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
...xAxisLabelRotation.config,
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isVertical(controls) : isHorizontal(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -181,6 +195,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
label: t('Axis Format'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -196,6 +212,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Logarithmic axis'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -210,6 +228,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('Draw split lines for minor axis ticks'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -224,6 +244,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
description: t('It’s not recommended to truncate axis in Bar chart.'),
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isHorizontal(controls) : isVertical(controls),
disableStash: true,
resetOnHide: false,
},
},
],
Expand All @@ -244,6 +266,8 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
visibility: ({ controls }: ControlPanelsContainerProps) =>
Boolean(controls?.truncateYAxis?.value) &&
(isXAxis ? isHorizontal(controls) : isVertical(controls)),
disableStash: true,
resetOnHide: false,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {

const renderControl = ({ name, config }: CustomControlItem) => {
const { controls, chart, exploreState } = props;
const { visibility, hidden, ...restConfig } = config;
const { visibility, hidden, disableStash, ...restConfig } = config;

// If the control item is not an object, we have to look up the control data from
// the centralized controls file.
Expand Down Expand Up @@ -529,7 +529,7 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {

return (
<StashFormDataContainer
shouldStash={isVisible === false}
shouldStash={isVisible === false && disableStash !== true}
fieldNames={[name]}
key={`control-container-${name}`}
>
Expand Down

0 comments on commit 97dde8c

Please sign in to comment.