Skip to content

Commit f024ea5

Browse files
committed
[FIX] table_style_editor_panel: disable "No Color" button
This PR introduces two changes: 1. Resolves a traceback error in the table style editor by disabling the "No Color" button when not applicable. 2. Prevents errors by validating color input earlier, ensuring that empty values are not processed when generating table color sets. closes #5347 Task: 4102704 X-original-commit: bd13a6c Signed-off-by: Rémi Rahir (rar) <[email protected]> Signed-off-by: Dhrutik Patel (dhrp) <[email protected]>
1 parent 23a005a commit f024ea5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/components/side_panel/table_style_editor_panel/table_style_editor_panel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, useExternalListener, useState } from "@odoo/owl";
2+
import { isColorValid } from "../../../helpers";
23
import { TABLE_STYLES_TEMPLATES, buildTableStyle } from "../../../helpers/table_presets";
34
import {
45
Color,
@@ -26,6 +27,8 @@ css/* scss */ `
2627
}
2728
`;
2829

30+
const DEFAULT_TABLE_STYLE_COLOR = "#3C78D8";
31+
2932
export interface TableStyleEditorPanelProps {
3033
onCloseSidePanel: () => void;
3134
styleId?: string;
@@ -63,7 +66,7 @@ export class TableStyleEditorPanel extends Component<
6366
: null;
6467
return {
6568
pickerOpened: false,
66-
primaryColor: editedStyle?.primaryColor || "#3C78D8",
69+
primaryColor: editedStyle?.primaryColor || DEFAULT_TABLE_STYLE_COLOR,
6770
selectedTemplateName: editedStyle?.templateName || "lightColoredText",
6871
styleName: editedStyle?.displayName || this.env.model.getters.getNewCustomTableStyleName(),
6972
};
@@ -74,7 +77,7 @@ export class TableStyleEditorPanel extends Component<
7477
}
7578

7679
onColorPicked(color: Color) {
77-
this.state.primaryColor = color;
80+
this.state.primaryColor = isColorValid(color) ? color : DEFAULT_TABLE_STYLE_COLOR;
7881
this.state.pickerOpened = false;
7982
}
8083

src/components/side_panel/table_style_editor_panel/table_style_editor_panel.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
</Section>
88
<Section class="'pt-1'">
99
<t t-set-slot="title">Style color</t>
10-
<RoundColorPicker currentColor="state.primaryColor" onColorPicked.bind="onColorPicked"/>
10+
<RoundColorPicker
11+
currentColor="state.primaryColor"
12+
onColorPicked.bind="onColorPicked"
13+
disableNoColor="true"
14+
/>
1115
</Section>
1216
<Section class="'pt-1'">
1317
<t t-set-slot="title">Style template</t>

0 commit comments

Comments
 (0)