Skip to content

[WC-3053] Filter empty option caption - Backport dw2.32 [mx10.21] #1748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: lts/data-widgets/2.32
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions automation/run-e2e/lib/update-test-project.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ async function updateAtlasTheme() {

rm("-rf", "tests/testProject/theme");

const release = await getLatestReleaseByName("Atlas UI - Theme Folder Files", config.atlasCoreReleaseUrl);

if (!release) {
throw new Error("Can't fetch latest Atlas UI theme release");
// Fetch the specific release by tag from GitHub API
const tag = "atlasui-theme-files-2024-01-25";
const releaseResponse = await fetchGithubRestAPI(`${config.atlasCoreReleaseUrl}/tags/${tag}`);
if (!releaseResponse.ok) {
throw new Error(`Can't fetch release for tag: ${tag}`);
}
const release = await releaseResponse.json();
if (!release.assets || release.assets.length === 0) {
throw new Error(`No assets found for release tag: ${tag}`);
}

const [{ browser_download_url }] = release.assets;
const downloadedPath = join(await usetmp(), config.nameForDownloadedAtlasTheme);
const outPath = await usetmp();
Expand All @@ -94,6 +98,10 @@ async function updateAtlasTheme() {
cp("-r", nativePath, themePath);

cp("-r", themePath, config.testProjectDir);
// Fix file permissions to ensure Docker can write to theme files
// The Atlas theme files are copied with read-only permissions
// but mxbuild needs to write to some generated files during build
sh.exec(`chmod -R +w "${config.testProjectDir}/themesource"`, { silent: true });
}

async function runReleaseScript() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@mixin scroll-shadow {
background:
/* Shadow Cover TOP */
/* Shadow Cover TOP */
linear-gradient(white 30%, rgba(255, 255, 255, 0)) center top,
/* Shadow Cover BOTTOM */ linear-gradient(rgba(255, 255, 255, 0), white 70%) center bottom,
/* Shadow TOP */ linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(197, 197, 197, 0.6)) center top,
Expand Down Expand Up @@ -138,7 +138,6 @@ $root: ".widget-dropdown-filter";
&-clear {
@include btn-with-cross;
align-items: center;
align-self: center;
display: flex;
flex-shrink: 0;
justify-self: end;
Expand All @@ -150,6 +149,11 @@ $root: ".widget-dropdown-filter";
&:has(+ #{$root}-toggle) {
border-inline-end: 1px solid var(--gray, #787d87);
}

&:focus-visible {
outline-offset: -2px;
outline: var(--brand-primary, $brand-primary) solid 1px;
}
}

&-state-icon {
Expand Down Expand Up @@ -262,9 +266,13 @@ $root: ".widget-dropdown-filter";
justify-content: center;
line-height: 1.334;
padding: var(--wdf-tag-padding);
margin: var(--spacing-smallest, 2px);
&:focus-visible {
outline: var(--brand-primary, #264ae5) auto 1px;
}
&:focus {
background-color: var(--color-primary-light, $color-primary-light);
}
}

#{$root}-input {
Expand All @@ -273,6 +281,14 @@ $root: ".widget-dropdown-filter";
width: initial;
}

&:not(:focus-within):not([data-empty]) {
#{$root}-input {
opacity: 0;
flex-shrink: 1;
min-width: 1px;
}
}

#{$root}-clear {
border-color: transparent;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Fixed

- We enhanced dropdown widget customization by separating texts for empty selection, empty option caption, and input placeholder. This change allows for more granular control over the widget's text configurations.

- We improved dropdown widget usability with enhanced keyboard navigation, visual feedback, and interaction behavior.

### Breaking changes

- Text configurations for empty option, empty selection, and input placeholder need to be reviewed and reconfigured.

## [2.10.1] - 2025-04-16

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ test.describe("datagrid-dropdown-filter-web", () => {

test.describe("using enumeration as attribute", () => {
test("shows the expected result", async ({ page }) => {
await page.click(".mx-name-datagrid1 .mx-name-dataGridDrop_downFilter1");
await page.waitForSelector(".widget-dropdown-filter-menu-slot > ul > li:nth-child(2)");
await page.click(".widget-dropdown-filter-menu-slot > ul > li:nth-child(2)");
await page.locator(".mx-name-datagrid1 .mx-name-dataGridDrop_downFilter1").click({ delay: 1 });
await page.waitForSelector(".widget-dropdown-filter-menu-slot > ul > li:nth-child(1)");
await page.locator(".widget-dropdown-filter-menu-slot > ul > li:nth-child(1)").click({ delay: 1 });
await page.waitForTimeout(300); // wait for filter to apply
await page.click("#DataGrid4-column0");
await page.locator("#DataGrid4-column0").click({ delay: 1 });
const cells = await page.$$eval(".mx-name-datagrid1 .td", elements =>
elements.map(element => element.textContent)
);
await expect(cells).toEqual(["10", "test", "test", "Yes", ""]);
});

test("shows the expected result with multiple selected items", async ({ page }) => {
await page.click(".mx-name-datagrid1 .mx-name-dataGridDrop_downFilter1");
await page.locator(".mx-name-datagrid1 .mx-name-dataGridDrop_downFilter1").click({ delay: 1 });
await page.waitForSelector(".widget-dropdown-filter-menu-slot > ul > li:nth-child(2)");
await page.click(".widget-dropdown-filter-menu-slot > ul > li:nth-child(2)");
await page.locator(".widget-dropdown-filter-menu-slot > ul > li:nth-child(1)").click({ delay: 1 });
await page.waitForSelector(".widget-dropdown-filter-menu-slot > ul > li:nth-child(3)");
await page.click(".widget-dropdown-filter-menu-slot > ul > li:nth-child(3)");
await page.locator(".widget-dropdown-filter-menu-slot > ul > li:nth-child(2)").click({ delay: 1 });
await page.waitForTimeout(300); // wait for filter to apply
await page.click("#DataGrid4-column0");
await page.locator("#DataGrid4-column0").click({ delay: 1 });
const cells = await page.$$eval(".mx-name-datagrid1 .td", elements =>
elements.map(element => element.textContent)
);
Expand All @@ -54,20 +54,20 @@ test.describe("datagrid-dropdown-filter-web", () => {

test.describe("using boolean as attribute", () => {
test("shows the expected result", async ({ page }) => {
await page.getByRole("combobox", { name: "Empty" }).click();
await page.getByRole("combobox", { name: "Active column filter" }).click({ delay: 1 });
const dropdownItem = await page.locator(".widget-dropdown-filter-menu-slot > ul > li:nth-child(3)");
await expect(dropdownItem).toHaveText("No");
await dropdownItem.click();
await page.locator("#DataGrid4-column1").click();
await dropdownItem.click({ delay: 1 });
await page.locator("#DataGrid4-column1").click({ delay: 1 });
const cells = await page.locator(".mx-name-datagrid1 .tr");
expect(cells).toHaveCount(1);
});

test("shows no results when no items selected", async ({ page }) => {
await page.getByRole("combobox", { name: "Empty" }).click();
await page.getByRole("combobox", { name: "Active column filter" }).click({ delay: 1 });
const dropdownItem = await page.locator(".widget-dropdown-filter-menu-slot > ul > li:nth-child(1)"); //the first item means none selected
await dropdownItem.click();
await page.locator("#DataGrid4-column1").click();
await dropdownItem.click({ delay: 1 });
await page.locator("#DataGrid4-column1").click({ delay: 1 });
const cells = await page.locator(".mx-name-datagrid1 .tr");
expect(cells).toHaveCount(4);
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test.describe("datagrid-dropdown-filter-web", () => {
test("show list of Companies with empty option on top of the list", async ({ page }) => {
const menu = () => page.locator("text=FMC Corp");

await page.locator(".mx-name-drop_downFilter2").click();
await page.locator(".mx-name-drop_downFilter2").click({ delay: 1 });
await expect(menu()).toBeVisible();
const list = page.locator(".widget-dropdown-filter-menu-slot > ul > li");
await expect(list).toHaveCount(21);
Expand All @@ -25,15 +25,15 @@ test.describe("datagrid-dropdown-filter-web", () => {
});

test("set value after option is clicked", async ({ page }) => {
const select = () => page.getByRole("columnheader", { name: "sort Company" }).getByLabel("Search");
const select = () => page.getByRole("combobox", { name: "Company column filter" });
const toggle = page.locator(".widget-dropdown-filter-toggle");
const menu = () => page.locator("text=FMC Corp");
const option1 = () => page.getByRole("option", { name: "Brown-Forman Corporation" });
const clickOutside = async () => page.locator("body").click();
const clickOutside = async () => page.locator("body").click({ delay: 1 });

await select().click();
await select().click({ delay: 1 });
await expect(menu()).toBeVisible();
await option1().click();
await option1().click({ delay: 1 });
await expect(toggle.nth(3)).toHaveText("Brown-Forman Corporation");
await clickOutside();
await expect(menu()).not.toBeVisible();
Expand All @@ -45,25 +45,25 @@ test.describe("datagrid-dropdown-filter-web", () => {

test.describe("multiselect", () => {
test("shows list of Roles", async ({ page }) => {
const select = () => page.getByRole("columnheader", { name: "Roles" }).getByLabel("Search");
const select = () => page.getByRole("combobox", { name: "Role column filter" });
const menu = () => page.locator("text=Economist");
const option1 = () => page.getByRole("option", { name: "Economist" });
const option2 = () => page.getByRole("option", { name: "Public librarian" });
const option3 = () => page.getByRole("option", { name: "Prison officer" });

await select().click();
await select().click({ delay: 1 });
await expect(menu().first()).toBeVisible();
await expect(option1()).toBeVisible();
await expect(option2()).toBeVisible();
await expect(option3()).toBeVisible();
});

test("does filtering when option is checked", async ({ page }) => {
const select = () => page.getByRole("columnheader", { name: "Roles" }).getByLabel("Search");
const select = () => page.getByRole("combobox", { name: "Role column filter" });
const option2 = () => page.getByRole("option", { name: "Public librarian" });

await select().click();
await option2().click();
await select().click({ delay: 1 });
await option2().click({ delay: 1 });
const rows = page.locator(".mx-name-dataGrid21 .tr");
await expect(rows).toHaveCount(5); // 4 rows + 1 header row
});
Expand All @@ -73,9 +73,9 @@ test.describe("datagrid-dropdown-filter-web", () => {
test("open menu with no options selected", async ({ page }) => {
const select = () => page.locator(".mx-name-drop_downFilter1");
const menu = () => page.getByRole("option", { name: "Environmental scientist" });
const clickOutside = async () => (await page.locator("body")).click();
const clickOutside = async () => (await page.locator("body")).click({ delay: 1 });

await select().click();
await select().click({ delay: 1 });
const checkedOptions = await menu().locator("input:checked");
await expect(checkedOptions).toHaveCount(0);
await clickOutside();
Expand All @@ -88,8 +88,8 @@ test.describe("datagrid-dropdown-filter-web", () => {
const menu = () => page.getByRole("option", { name: "Environmental scientist" });
const option1 = () => page.getByRole("option", { name: "Environmental scientist" });

await select().click();
await option1().click();
await select().click({ delay: 1 });
await option1().click({ delay: 1 });
const checkedOptions = await menu().locator("input:checked");
await expect(checkedOptions).toHaveCount(1);
await expect(checkedOptions.first()).toBeChecked();
Expand All @@ -106,9 +106,9 @@ test.describe("datagrid-dropdown-filter-web", () => {
const option1 = () => page.getByRole("option", { name: "Environmental scientist" });
const option2 = () => page.getByRole("option", { name: "Trader" });

await select().click();
await option1().click();
await option2().click();
await select().click({ delay: 1 });
await option1().click({ delay: 1 });
await option2().click({ delay: 1 });
const checkedOptions = await menu().locator("input:checked");
await expect(checkedOptions).toHaveCount(2);
await expect(checkedOptions.first()).toBeChecked();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mendix/datagrid-dropdown-filter-web",
"widgetName": "DatagridDropdownFilter",
"version": "2.10.1",
"version": "2.32.0",
"description": "",
"copyright": "© Mendix Technology BV 2025. All rights reserved.",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export function getProperties(values: DatagridDropdownFilterPreviewProps, defaul
if (values.filterable) {
hidePropertyIn(defaultProperties, values, "clearable");
hidePropertyIn(defaultProperties, values, "emptyOptionCaption");
} else {
hidePropertyIn(defaultProperties, values, "filterInputPlaceholderCaption");
}

if (!showSelectedItemsStyle) {
Expand Down Expand Up @@ -54,7 +56,7 @@ export const getPreview = (values: DatagridDropdownFilterPreviewProps, isDarkMod
text({
fontColor: palette.text.secondary,
italic: true
})(values.emptyOptionCaption || " ")
})(values.emptySelectionCaption || " ")
],
grow: 1
} as ContainerProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ function Preview(props: DatagridDropdownFilterPreviewProps): ReactElement {
return (
<Select
className={props.class}
ariaLabel={props.ariaLabel}
style={parseStyle(props.style)}
options={[]}
empty={!props.clearable}
clearable={props.clearable}
showCheckboxes={false}
value={getPreviewValue(props)}
onClear={noop}
useSelectProps={() => ({ items: [] })}
Expand All @@ -25,11 +27,7 @@ const noop = (): void => {};

function getPreviewValue(props: DatagridDropdownFilterPreviewProps): string {
let value = props.defaultValue;
if (!props.filterable) {
value ||= props.emptyOptionCaption || "Select";
} else {
value ||= "Search";
}
value ||= props.emptySelectionCaption || (props.filterable ? "Search" : "Select");
return value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RefFilterContainer } from "./components/RefFilterContainer";

function Container(props: DatagridDropdownFilterContainerProps & Select_FilterAPIv2): React.ReactElement {
const commonProps = {
ariaLabel: props.ariaLabel?.value,
ariaLabel: props.ariaLabel?.value ?? "",
className: props.class,
tabIndex: props.tabIndex,
styles: props.style,
Expand All @@ -16,7 +16,9 @@ function Container(props: DatagridDropdownFilterContainerProps & Select_FilterAP
parentChannelName: props.parentChannelName,
name: props.name,
multiselect: props.multiSelect,
emptyCaption: props.emptyOptionCaption?.value,
emptyOptionCaption: props.emptyOptionCaption?.value ?? "",
emptySelectionCaption: props.emptySelectionCaption?.value ?? "",
placeholder: props.filterInputPlaceholderCaption?.value ?? "",
defaultValue: props.defaultValue?.value,
filterable: props.filterable,
selectionMethod: props.selectionMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<property key="emptyOptionCaption" type="textTemplate" required="false">
<caption>Empty option caption</caption>
<description />
<translations>
<translation lang="en_US">None</translation>
<translation lang="nl_NL">Niets</translation>
</translations>
</property>
<property key="clearable" type="boolean" defaultValue="true">
<caption>Clearable</caption>
Expand Down Expand Up @@ -83,13 +87,32 @@
</property>
</propertyGroup>
</propertyGroup>
<propertyGroup caption="Accessibility">
<propertyGroup caption="Advanced">
<propertyGroup caption="Accessibility">
<property key="ariaLabel" type="textTemplate" required="false">
<caption>Input caption</caption>
<description>Assistive technology will read this upon reaching the input element.</description>
</property>
</propertyGroup>
<propertyGroup caption="Texts">
<property key="emptySelectionCaption" type="textTemplate" required="false">
<caption>Empty selection caption</caption>
<description>This text is shown if no options are selected. For example 'Select color' or 'No options are selected'.</description>
<translations>
<translation lang="en_US">Select</translation>
<translation lang="nl_NL">Selecteer</translation>
</translations>
</property>

<property key="filterInputPlaceholderCaption" type="textTemplate" required="false">
<caption>Filter input placeholder</caption>
<description>This text is shown as placeholder for filterable filters. For example 'Type to search'.</description>
<translations>
<translation lang="en_US">Search</translation>
<translation lang="nl_NL">Zoeken</translation>
</translations>
</property>
</propertyGroup>
</propertyGroup>
</properties>
</widget>
Loading
Loading