Skip to content

Commit 54e5ffa

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fix/menuRoles-CMEM-7708
2 parents bb7766f + 3dc0b87 commit 54e5ffa

14 files changed

Lines changed: 664 additions & 252 deletions

‎CHANGELOG.md‎

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,39 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fix misused menu roles in selection popups and overlays
12+
- `<MultiSuggestField />`
13+
- improve keyboard navigation, tag removal and focus handling
14+
- improve screen reader labels and selection announcements
15+
- preserve filters and keep the dropdown open when toggling existing options
16+
17+
## [26.2.1] - 2026-11-02
18+
19+
### Fixed
20+
21+
- resolution for package `@ungap/structured-clone` was set to `v1.3.1` because it was the source why Wiz and Trivy scanners detected vulnerability issues for the gui elements package
22+
23+
## [26.2.0] - 2026-10-05
24+
925
### Added
1026

1127
- `<CodeEditor />`
1228
- documents the built-in Escape then Tab sequence for moving focus out of the editor when Tab is configured to indent
1329
- shows a compact keyboard navigation hint in a bottom CodeMirror panel when Tab is configured to indent
1430
- `keyboardHint` accepts a custom string or element for localized instructions, the default instruction is marked as English
1531
- `<Switch />`
16-
- `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: `true`
32+
- `noDrag` property: adds the `nodrag` class to the Switch element. Default: `true`
1733
- `<Markdown />`
18-
- Added `cutOff` property to set maximum number of raw Markdown characters to render
34+
- `cutOff` property: sets the maximum number of raw Markdown characters to render
1935
- `<Label />`
2036
- `hidden` property: label is not displayed but stays accessible for screen readers and keyboard navigation
2137
- `<FieldItem />`
2238
- label, input element, helper text and message are connected to each other automatically now
2339
- each part without an own `id` gets one based on a unique ID of the field item
2440
- the label refers to the input element via `for`, or via `aria-labelledby` on the input element if the label is not displayed as `label` element
25-
- an already set `for` is only kept if it refers to the ID of the input element of the field item
41+
- an already set `for` is only kept if it refers to the ID of an input element of the field item, e.g. to a second input element
2642
- helper text and message are referred by the input element via `aria-describedby`
2743
- `input`, `textarea`, `select`, the toggle button of `<Select />` and the editable area of `<CodeEditor />` are supported as input element
2844
- input elements that cannot be referenced by `for`, e.g. the editable area of the code editor, are connected via `aria-labelledby`
@@ -32,7 +48,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
3248
- `preventAriaAttribution` property: prevents this automatic connection of the field item parts
3349
- `<Modal />`
3450
- `role`, `aria-label`, `aria-labelledby` and `aria-describedby` properties: they are set on the dialog element inside the modal overlay
35-
- `role` is `dialog` by default, but it is removed again if neither a label nor a description is available; a console warning points this out when the modal is opened
51+
- `role` is `dialog` by default, but it is removed again if neither `aria-label` nor `aria-labelledby` is available; a console warning points this out when the modal is opened
3652
- `aria-modal` is set together with the `role`, so it is left out as well if the `role` was removed
3753
- it is `true` for the modal that was opened last according to the `ModalContext`, otherwise it is `false`
3854
- if no `ModalContext` is provided, then the modals cannot know about each other, so each of them claims modality
@@ -43,7 +59,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
4359
- explicitly given values are never overwritten
4460
- if neither `title`, `aria-label` nor `aria-labelledby` is given for an alert, then the `intent` level is used as fallback for `aria-label`, so the alert dialog always has an accessible name
4561
- new `utils` methods:
46-
- `truncateMarkdownDisplay`: helper function to iterate over `Markdown` renderings to improve the experienced `cutOff` value
62+
- `truncateMarkdownDisplay`: helper function to iterate over `Markdown` renderings to find a `cutOff` value that matches the visible text length
63+
- `ClassNames`
64+
- `ReactFlow`: helper classes for react-flow, e.g. `preventAllActions` to prevent drag, pan and wheel actions
4765
- new icons:
4866
- `toggler-treenode-closed`
4967
- `toggler-treenode-expanded`
@@ -54,6 +72,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
5472
- Carbon, Codemirror, React-Flow
5573
- minimum node version (`engines.node`) is `18.19.0` now
5674
- the build of the ESM distribution needs a synchronous `import.meta.resolve`, which is only available since this version
75+
- `<Switch />`
76+
- the `nodrag` class is added by default now, use `noDrag={false}` to prevent this
5777
- `<FieldItem />`
5878
- the used `Label` element gets the `eccgui-fielditem__label` class now
5979
- `<AlertDialog />`
@@ -64,22 +84,28 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6484
- before only an internal reference was updated, which never triggered any re-render
6585
- the component that provides the context via `useModalContext` is re-rendered on every change of the stack, but not if a change does not affect it, e.g. when a modal is closed that was never registered as open
6686
- `openModalStack()` still returns the current stack synchronously, also directly after `setModalOpen()` was called
87+
- closing a modal only removes this modal from the stack, modals that were opened after it stay in the stack as long as they are open
88+
- before they were considered as closed, too, so the still visible top most modal was not known as the top most one anymore
6789
- `<CodeEditor />`
6890
- `enableTab` overrides the Tab behaviour derived from `mode` and `tabIntentStyle` now, if it is set
6991
- `enableTab={false}` lets Tab always move the focus, even for modes with tab indentation
7092
- if it is not set, Tab is still handled as indentation for modes with `tabIntentStyle="tab"`
7193
- `<AutoSuggestion />`
7294
- Tab is only handled in the editor if `useTabForCompletions` is enabled, as side effect it currently also enables tab indentation
7395
- `<StringPreviewContentBlobToggler />`
74-
- `allowedHtmlElementsInPreview` option is set to inline elements on default
75-
- uses now the `Markdown.cutOff` property
76-
- this enables Markdown rendering even if the preview need to be shortened
96+
- `allowedHtmlElementsInPreview` option is set to inline elements by default
97+
- now uses the `Markdown.cutOff` property
98+
- this enables Markdown rendering even if the preview needs to be shortened
7799
- this may lead to slightly different preview lengths
78100

101+
### Deprecated
102+
103+
- `preventReactFlowActionsClasses`: use `ClassNames.ReactFlow.preventAllActions`, it will be removed in v27
104+
79105
### Fixed
80106

81107
- `<PropertyValuePair />`
82-
- fix description and story to point out that `PropertyValueList` need always to be used as wrapper
108+
- fix description and story to point out that `PropertyValueList` always needs to be used as wrapper
83109
- `<ApplicationViewability />`
84110
- `show={"print"}` and `hide={"screen"}` content is still accessible by screen readers
85111
- `<Label />`
@@ -88,19 +114,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88114
- fix color of first action button in info card
89115
- BOM issue on compressed stylesheet
90116
- first rule `selector` becomes `BOM:selector` that is valid but will never apply
91-
- we fixed this problem by adding a dummy rule as first rule
117+
- fixed by adding a dummy rule as first rule
92118
- ESM distribution
93119
- the imports of the `@codemirror/legacy-modes` modes were written with an additional `.js` suffix, but the `exports` map of this package only provides the extension-less sub paths, so they were expanded to unresolvable paths like `mode/jinja2.js.js`
94120
- Storybook
95121
- the `<Tab />` story imported the package root directory, this way the `exports` field of our own `package.json` pulled the built `dist/esm/` output into the preview bundle instead of the sources, and the Storybook build failed as soon as `dist/` existed
96122
- the webpack configuration excludes `dist/` from module resolution now, so the sources are always used even if a story references the package root
97-
- Added explicitly `assert` dependency
98-
- the linter of `<CodeEditor />` uses `jshint`, which imports `console-browserify`, and this package requires the node core modules `assert` and `util` without declaring them; bundlers based on webpack 5 do not provide shims for node core modules anymore, so the polyfill (and `util` together with it) is part of the delivery now
99-
- Fix misused menu roles in selection popups and overlays
100-
- `<MultiSuggestField />`
101-
- improve keyboard navigation, tag removal and focus handling
102-
- improve screen reader labels and selection announcements
103-
- preserve filters and keep the dropdown open when toggling existing options
123+
- Explicitly added `assert` and `util` dependencies
124+
- the linter of `<CodeEditor />` uses `jshint`, which imports `console-browserify`, and this package requires the node core modules `assert` and `util` without declaring them; bundlers based on webpack 5 do not provide shims for node core modules anymore, so both polyfills are part of the delivery now
104125

105126
### Deprecated
106127

‎package.json‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@eccenca/gui-elements",
33
"description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
4-
"version": "26.1.0",
4+
"version": "26.2.1",
55
"license": "Apache-2.0",
66
"homepage": "https://github.com/eccenca/gui-elements",
77
"bugs": "https://github.com/eccenca/gui-elements/issues",
@@ -118,13 +118,13 @@
118118
"@eslint/compat": "^2.1.0",
119119
"@eslint/eslintrc": "^3.3.6",
120120
"@eslint/js": "^10.0.1",
121-
"@storybook/addon-a11y": "^10.5.10",
122-
"@storybook/addon-docs": "^10.5.10",
123-
"@storybook/addon-links": "^10.5.10",
121+
"@storybook/addon-a11y": "^10.6.5",
122+
"@storybook/addon-docs": "^10.6.5",
123+
"@storybook/addon-links": "^10.6.5",
124124
"@storybook/addon-webpack5-compiler-babel": "^4.0.1",
125-
"@storybook/cli": "^10.5.10",
126-
"@storybook/react": "^10.5.10",
127-
"@storybook/react-webpack5": "^10.5.10",
125+
"@storybook/cli": "^10.6.5",
126+
"@storybook/react": "^10.6.5",
127+
"@storybook/react-webpack5": "^10.6.5",
128128
"@testing-library/dom": "^10.4.1",
129129
"@testing-library/jest-dom": "^7.0.1",
130130
"@testing-library/react": "^16.3.2",
@@ -160,7 +160,7 @@
160160
"rimraf": "^6.1.3",
161161
"sass": "^1.103.1",
162162
"sass-loader": "^17.0.0",
163-
"storybook": "^10.5.10",
163+
"storybook": "^10.6.5",
164164
"style-loader": "^4.0.0",
165165
"stylelint": "^17.14.1",
166166
"stylelint-config-recess-order": "^7.8.0",
@@ -182,7 +182,19 @@
182182
"**/lodash": "^4.18.1",
183183
"**/minimatch": "^3.1.4",
184184
"**/postcss": "^8.5.18",
185-
"**/serialize-javascript": "^7.0.5"
185+
"**/serialize-javascript": "^7.0.5",
186+
"**/brace-expansion": "^1.1.20",
187+
"jest/**/js-yaml": "^3.15.2",
188+
"babel-jest/**/js-yaml": "^3.15.2",
189+
"stylelint/**/js-yaml": "^4.3.2",
190+
"@storybook/react-webpack5/**/js-yaml": "^4.3.2",
191+
"@eslint/eslintrc/**/js-yaml": "^4.3.2",
192+
"**/fast-uri": "^3.1.6",
193+
"**/browserslist": "^4.28.7",
194+
"@storybook/react-webpack5/**/webpack-dev-middleware": "^7.4.6",
195+
"**/source-map-js": "^1.2.2",
196+
"**/zod": "^4.6.6",
197+
"**/@ungap/structured-clone": "^1.3.1"
186198
},
187199
"husky": {
188200
"hooks": {

‎src/cmem/ContentBlobToggler/StringPreviewContentBlobToggler.tsx‎

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,54 @@ export function StringPreviewContentBlobToggler({
6363
previewString = useOnlyPart(content, regexFirstMarkdownSection);
6464
}
6565

66-
let enableToggler = previewString !== content;
66+
// Measuring and truncating a Markdown preview renders the Markdown multiple times to static markup, so it is only
67+
// re-calculated if one of its inputs changes, and not on every re-render, e.g. of a long list containing togglers.
68+
const { truncatedPreviewContent, isTruncated } = React.useMemo((): {
69+
truncatedPreviewContent: React.JSX.Element | string;
70+
isTruncated: boolean;
71+
} => {
72+
if (!renderPreviewAsMarkdown) {
73+
if (previewMaxLength) {
74+
const previewText = utils.reduceToText(previewString, { decodeHtmlEntities: true });
75+
if (previewText.length > previewMaxLength) {
76+
return { truncatedPreviewContent: previewText.slice(0, previewMaxLength), isTruncated: true };
77+
}
78+
}
79+
return { truncatedPreviewContent: previewString, isTruncated: false };
80+
}
6781

68-
let previewContent = renderPreviewAsMarkdown ? (
69-
<Markdown key="markdown-content" allowedElements={allowedHtmlElementsInPreview}>
70-
{previewString}
71-
</Markdown>
72-
) : (
73-
previewString
74-
);
82+
if (!previewMaxLength) {
83+
return {
84+
truncatedPreviewContent: (
85+
<Markdown key="markdown-content" allowedElements={allowedHtmlElementsInPreview}>
86+
{previewString}
87+
</Markdown>
88+
),
89+
isTruncated: false,
90+
};
91+
}
7592

76-
if (
77-
previewMaxLength &&
78-
utils.reduceToText(previewContent, { decodeHtmlEntities: true }).length > previewMaxLength
79-
) {
80-
previewContent = renderPreviewAsMarkdown
81-
? utils.truncateMarkdownDisplay(
82-
<Markdown
83-
key="markdown-content"
84-
allowedElements={allowedHtmlElementsInPreview}
85-
cutOff={previewMaxLength}
86-
cutOffSuffix={""}
87-
>
88-
{previewString}
89-
</Markdown>,
90-
{ decodeHtmlEntities: true },
91-
)
92-
: utils.reduceToText(previewContent, { decodeHtmlEntities: true }).slice(0, previewMaxLength);
93-
enableToggler = true;
94-
}
93+
// `truncateMarkdownDisplay` already measures the complete Markdown display first and returns it without
94+
// `cutOff` if it is short enough, so it is not measured here a second time.
95+
const markdownPreview = utils.truncateMarkdownDisplay(
96+
<Markdown
97+
key="markdown-content"
98+
allowedElements={allowedHtmlElementsInPreview}
99+
cutOff={previewMaxLength}
100+
cutOffSuffix={""}
101+
>
102+
{previewString}
103+
</Markdown>,
104+
{ decodeHtmlEntities: true },
105+
);
106+
return {
107+
truncatedPreviewContent: markdownPreview,
108+
isTruncated: markdownPreview.props.cutOff !== undefined,
109+
};
110+
}, [previewString, previewMaxLength, renderPreviewAsMarkdown, allowedHtmlElementsInPreview]);
111+
112+
const enableToggler = previewString !== content || isTruncated;
113+
let previewContent = truncatedPreviewContent;
95114

96115
if (!enableToggler && noTogglerContentSuffix) {
97116
previewContent = (

‎src/cmem/ContentBlobToggler/tests/StringPreviewContentBlobToggler.test.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render, RenderResult } from "@testing-library/react";
33

44
import "@testing-library/jest-dom";
55

6+
import { utils } from "../../../common";
67
import {
78
StringPreviewContentBlobToggler,
89
StringPreviewContentBlobTogglerProps,
@@ -72,6 +73,22 @@ describe("StringPreviewContentBlobToggler", () => {
7273
textMustNotExist(queryByText, "https://github.com/"); // test if Markdown was rendered
7374
textMustNotExist(queryByText, "show more");
7475
});
76+
it("should not truncate the Markdown preview again when re-rendered with unchanged content", () => {
77+
const truncateSpy = jest.spyOn(utils, "truncateMarkdownDisplay");
78+
const props = StringPreviewContentBlobTogglerStory.args as StringPreviewContentBlobTogglerProps;
79+
try {
80+
const { rerender, queryByText } = render(<StringPreviewContentBlobToggler {...props} />);
81+
rerender(<StringPreviewContentBlobToggler {...props} />);
82+
expect(truncateSpy).toHaveBeenCalledTimes(1);
83+
textMustExist(queryByText, "show more");
84+
85+
rerender(<StringPreviewContentBlobToggler {...props} previewMaxLength={144} />);
86+
expect(truncateSpy).toHaveBeenCalledTimes(2);
87+
textMustNotExist(queryByText, "show more");
88+
} finally {
89+
truncateSpy.mockRestore();
90+
}
91+
});
7592
it("should not use Markdown rendering on `renderPreviewAsMarkdown={false}`", () => {
7693
const { queryByText } = render(
7794
<StringPreviewContentBlobToggler

‎src/cmem/markdown/Markdown.stories.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,3 @@ CutOffWithBoldText.args = {
164164
children: "Some intro text and then **an important warning** and more text afterwards here.",
165165
cutOff: 35,
166166
};
167-

‎src/cmem/markdown/truncateMarkdown.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ describe("truncateMarkdown", () => {
8787
expect(result).toBe("```\nsome code\n```\n\n...");
8888
});
8989

90+
it("keeps the opening fence line complete when cutOff falls inside its info string", () => {
91+
const content = "```javascript\nconst a = 1;\nconst b = 2;\n```";
92+
expect(truncateMarkdown(content, 5, "...")).toBe("```javascript\nconst\n```\n\n...");
93+
});
94+
95+
it("keeps the opening fence marker complete when cutOff falls inside it", () => {
96+
const content = "~~~~\nsome code line here\n~~~~";
97+
expect(truncateMarkdown(content, 2, "...")).toBe("~~~~\nsome\n~~~~\n\n...");
98+
});
99+
100+
it("keeps an empty fence complete when cutOff falls inside its opening line", () => {
101+
const content = "```javascript\n\n```\n\nSome text after the empty code block.";
102+
expect(truncateMarkdown(content, 5, "...")).toBe("```javascript\n```\n\n...");
103+
});
104+
90105
it("cuts a table only at complete rows", () => {
91106
const content = ["| Name | Value |", "| --- | --- |", "| first | row |", "| second | row |"].join("\n");
92107
const result = truncateMarkdown(content, content.indexOf("second") + 3, "...");
@@ -233,6 +248,25 @@ describe("truncateMarkdown", () => {
233248
expect(truncateMarkdown(content, 32, "...")).toBe("Some intro words and\n\n...");
234249
});
235250

251+
it("keeps a leading bold span complete when it is followed by punctuation instead of a space", () => {
252+
const content = "**Important note**: this is a long text that goes on and on.";
253+
expect(truncateMarkdown(content, 5, "...")).toBe("**Important note**\n\n...");
254+
});
255+
256+
it("does not fall back to a word boundary inside a span that ends right before the cutOff", () => {
257+
const content = "Some intro text and then **an important warning**, and more text afterwards here.";
258+
expect(truncateMarkdown(content, content.indexOf(","), "...")).toBe(
259+
"Some intro text and then **an important warning**\n\n...",
260+
);
261+
});
262+
263+
it("does not fall back to a word boundary inside a link that ends right before the cutOff", () => {
264+
const content = "Some text (see [the docs](https://example.com)), and more text afterwards here.";
265+
expect(truncateMarkdown(content, content.indexOf(","), "...")).toBe(
266+
"Some text (see [the docs](https://example.com)\n\n...",
267+
);
268+
});
269+
236270
it("does not treat intra-word underscores as emphasis", () => {
237271
const content = "Some intro words and snake_case_name_here plus more words to cut here somewhere.";
238272
expect(truncateMarkdown(content, 30, "...")).toBe("Some intro words and\n\n...");

0 commit comments

Comments
 (0)