Skip to content

Commit c522a84

Browse files
committed
chore: move caption error to warning category, add <...> fallback for empty
While this check is still helpful, this check might go wrong in a scenario with multiple languages involved. Prevent this check from showstopping app from running by switching this check to a warning. Also fix warnings in tests
1 parent 3f372f8 commit c522a84

File tree

6 files changed

+51
-24
lines changed

6 files changed

+51
-24
lines changed

packages/pluggableWidgets/datagrid-web/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We changed the severity for missing column captions from error to warning
12+
913
## [2.30.3] - 2025-03-20
1014

1115
### Fixed

packages/pluggableWidgets/datagrid-web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@mendix/datagrid-web",
33
"widgetName": "Datagrid",
4-
"version": "2.30.3",
4+
"version": "2.30.4",
55
"description": "",
66
"copyright": "© Mendix Technology BV 2025. All rights reserved.",
77
"license": "Apache-2.0",

packages/pluggableWidgets/datagrid-web/src/components/ColumnSelector.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function ColumnSelector(props: ColumnSelectorProps): ReactElement {
112112
onChange={onChangeStub}
113113
/>
114114
<label htmlFor={`${props.id}_checkbox_toggle_${index}`} style={{ pointerEvents: "none" }}>
115-
{column.header}
115+
{column.header.trim() || "<...>"}
116116
</label>
117117
</li>
118118
) : null;

packages/pluggableWidgets/datagrid-web/src/components/__tests__/ColumnSelector.spec.tsx

+43-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createElement } from "react";
2-
import { render, screen } from "@testing-library/react";
2+
import { act, render, screen } from "@testing-library/react";
33
import userEvent from "@testing-library/user-event";
44
import "@testing-library/jest-dom";
55
import { ColumnSelector, ColumnSelectorProps } from "../ColumnSelector";
@@ -20,7 +20,9 @@ describe("Column Selector", () => {
2020
expect(document.body).toHaveFocus();
2121

2222
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
23-
await user.click(screen.getByRole("button"));
23+
await act(async () => {
24+
await user.click(screen.getByRole("button"));
25+
});
2426

2527
const element = document.querySelector(".column-selectors");
2628
expect(element?.classList.contains("overflow")).toBe(false);
@@ -31,9 +33,11 @@ describe("Column Selector", () => {
3133
expect(document.body).toHaveFocus();
3234

3335
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
34-
await user.click(screen.getByRole("button"));
36+
await act(async () => {
37+
await user.click(screen.getByRole("button"));
38+
});
3539

36-
jest.runOnlyPendingTimers();
40+
jest.advanceTimersByTime(100);
3741

3842
const items = screen.getAllByRole("menuitem");
3943
expect(items[0]).toHaveFocus();
@@ -44,16 +48,20 @@ describe("Column Selector", () => {
4448
expect(document.body).toHaveFocus();
4549

4650
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
47-
await user.click(screen.getByRole("button"));
51+
await act(async () => {
52+
await user.click(screen.getByRole("button"));
53+
});
4854

49-
jest.runOnlyPendingTimers();
55+
jest.advanceTimersByTime(100);
5056

5157
const items = screen.getAllByRole("menuitem");
5258
expect(items[0]).toHaveFocus();
5359

54-
await user.tab({ shift: true });
60+
await act(async () => {
61+
await user.tab({ shift: true });
62+
});
5563

56-
jest.runOnlyPendingTimers();
64+
jest.advanceTimersByTime(100);
5765

5866
expect(screen.getByRole("button")).toHaveFocus();
5967
});
@@ -81,17 +89,24 @@ describe("Column Selector", () => {
8189
expect(document.body).toHaveFocus();
8290

8391
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
84-
await user.click(screen.getByRole("button"));
85-
86-
jest.runOnlyPendingTimers();
92+
await act(async () => {
93+
await user.click(screen.getByRole("button"));
94+
});
95+
jest.advanceTimersByTime(100);
8796

8897
const items = screen.getAllByRole("menuitem");
8998
expect(items[0]).toHaveFocus();
90-
await user.tab();
91-
expect(items[1]).toHaveFocus();
92-
await user.tab();
9399

94-
jest.runOnlyPendingTimers();
100+
await act(async () => {
101+
await user.tab();
102+
});
103+
jest.advanceTimersByTime(100);
104+
105+
expect(items[1]).toHaveFocus();
106+
await act(async () => {
107+
await user.tab();
108+
});
109+
jest.advanceTimersByTime(100);
95110

96111
expect(screen.getByRole("button")).toHaveFocus();
97112
});
@@ -130,19 +145,26 @@ describe("Column Selector", () => {
130145
expect(document.body).toHaveFocus();
131146

132147
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
133-
await user.click(screen.getByRole("button"));
134148

135-
jest.runOnlyPendingTimers();
149+
await act(async () => {
150+
await user.click(screen.getByRole("button"));
151+
});
152+
jest.advanceTimersByTime(100);
136153

137154
const items = screen.getAllByRole("menuitem");
138155
expect(items).toHaveLength(3);
139156
expect(items[0]).toHaveFocus();
140157

141-
await user.tab();
142-
expect(items[1]).toHaveFocus();
143-
await user.keyboard("{Escape}");
158+
await act(async () => {
159+
await user.tab();
160+
});
161+
jest.advanceTimersByTime(100);
144162

145-
jest.runOnlyPendingTimers();
163+
expect(items[1]).toHaveFocus();
164+
await act(async () => {
165+
await user.keyboard("{Escape}");
166+
});
167+
jest.advanceTimersByTime(100);
146168

147169
expect(screen.getByRole("button")).toHaveFocus();
148170
});

packages/pluggableWidgets/datagrid-web/src/consistency-check.ts

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const checkHidableSettings = (
111111
if (values.columnsHidable && column.hidable !== "no" && !column.header) {
112112
return {
113113
property: columnPropPath("hidable", index),
114+
severity: "warning",
114115
message:
115116
"A caption is required if 'Can hide' is Yes or Yes, hidden by default. This can be configured under 'Column capabilities' in the column item properties"
116117
};

packages/pluggableWidgets/datagrid-web/src/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="Datagrid" version="2.30.3" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="Datagrid" version="2.30.4" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="Datagrid.xml" />
66
</widgetFiles>

0 commit comments

Comments
 (0)