Skip to content

[WC-3314] Combobox: mitigate issue with empty string to executeAction()#2305

Open
r0b1n wants to merge 1 commit into
mainfrom
WC-3314/combobox-empty-string-execute-action
Open

[WC-3314] Combobox: mitigate issue with empty string to executeAction()#2305
r0b1n wants to merge 1 commit into
mainfrom
WC-3314/combobox-empty-string-execute-action

Conversation

@r0b1n

@r0b1n r0b1n commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator
  • Normalize empty string filterValue to undefined before passing to onChangeFilterInputEvent.execute() to prevent widget crash
  • Add changelog entry for the fix

There is a test project in related WTF story. Check that after the change there is not crash when input is cleared.

@r0b1n r0b1n requested a review from a team as a code owner July 3, 2026 15:25
@r0b1n r0b1n changed the title fix(combobox-web): WC-3314 [Combobox] Mitigate issue with empty string to executeAction() [WC-3314] Combobox: mitigate issue with empty string to executeAction() Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
packages/pluggableWidgets/combobox-web/src/hooks/useGetSelector.ts Normalize empty string filterValue to undefined before executing action
packages/pluggableWidgets/combobox-web/CHANGELOG.md Add [Unreleased] entry for the fix

Skipped (out of scope): dist/, pnpm-lock.yaml


Findings

Low — filterValue || undefined coerces all falsy values, not just empty string

File: packages/pluggableWidgets/combobox-web/src/hooks/useGetSelector.ts line 16

Problem: filterValue || undefined converts any falsy value to undefined, not just "". For the current string | undefined type this is correct in practice, but an explicit check better documents intent and is immune to future type widening.

Fix:

filterInput: filterValue !== "" ? filterValue : undefined

Non-blocking — the current fix is correct for all values that can arrive here.


Low — No regression test for the empty-string guard

File: packages/pluggableWidgets/combobox-web/src/hooks/useGetSelector.ts

Problem: There is no unit test asserting that an empty-string filterValue causes execute to be called with { filterInput: undefined }. Without a test the bug can silently regress.

Fix: Add tests using actionValue() from @mendix/widget-plugin-test-utils:

it("passes undefined when filterValue is empty string", () => {
    const action = actionValue();
    onInputValueChange(action, "");
    expect(action.execute).toHaveBeenCalledWith({ filterInput: undefined });
});
it("passes value through when filterValue is non-empty", () => {
    const action = actionValue();
    onInputValueChange(action, "foo");
    expect(action.execute).toHaveBeenCalledWith({ filterInput: "foo" });
});

Positives

  • CHANGELOG entry is user-facing only with no implementation detail leakage.
  • Fix correctly checks canExecute and isExecuting before calling execute(), following the Mendix ActionValue contract.
  • The change is minimal and surgical — only the one offending argument is touched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant