Skip to content

[WC-3533]: Fix/combobox on change - #2379

Open
r0b1n wants to merge 6 commits into
mainfrom
fix/combobox-onChange
Open

[WC-3533]: Fix/combobox on change#2379
r0b1n wants to merge 6 commits into
mainfrom
fix/combobox-onChange

Conversation

@r0b1n

@r0b1n r0b1n commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Pull request type

Refactoring (e.g. file rename, variable rename, etc.)


Description

Previously we were calling the event defined as OnChange seprately from the attributes and associations. In the code we were calling it manually to emulate the framework behaviour because of some istorical reasons. At this moment analysis says that we can actually attach the onChange to attributes and association and make the framework handle this action automatically.

This is needed to mitigate the issue with a race condition between editing and calling actions. At the moment if association being edited is also part of the onCHange action parameters, the action (nanoflow) gets stale parameters, so when changing from Options 1 to Option 2 and then immediately calling manual onChange, the nanoflow gets Option 1, while user just changed Option 1 to Option 2.

This refactoring passes the responsibility of handing the race condition to the framework's built in functionality.

What is still broken

As I implemented this change, this revealed a possible bug in the framework where instead of stale parameter, the prameter is not passed at all. 😅 Waiting for the team to confirm if it's a bug on their side. For now one e2e test is expected to be broken.

What should be covered while testing?

Check that all existing OnChange actions are still working as expected for different types of attributes and association. This PR introduces e2e tests that cover majority of scenarios, there might be some I missed. Test pages are committed in the test project and stil lcompatible with 10.22, so you can check with old version of the widget.

@r0b1n
r0b1n requested a review from a team as a code owner August 12, 2026 14:12
@r0b1n r0b1n changed the title Fix/combobox on change [WC-3533]: Fix/combobox on change Aug 12, 2026
@r0b1n
r0b1n force-pushed the fix/combobox-onChange branch from 9b2b87e to 3ab7bbd Compare August 19, 2026 13:43
@github-actions

This comment has been minimized.

@r0b1n
r0b1n force-pushed the fix/combobox-onChange branch from 3ab7bbd to c0b3b59 Compare August 19, 2026 14:45
@github-actions

This comment has been minimized.

gjulivan
gjulivan previously approved these changes Aug 31, 2026
@github-actions

This comment has been minimized.

leonardomendix
leonardomendix previously approved these changes Sep 9, 2026
@r0b1n
r0b1n force-pushed the fix/combobox-onChange branch from e21b951 to 5097ebe Compare September 9, 2026 13:47
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

AI Code Review

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


What was reviewed

File Change
src/Combobox.xml Adds onChange="onChangeEvent" to 5 attribute/association properties
typings/ComboboxProps.d.ts Removes onChangeEvent?: ActionValue from ComboboxContainerProps (now platform-managed)
src/helpers/Association/BaseAssociationSelector.ts Removes onChangeEvent field and executeAction call from base setValue
src/helpers/Association/AssociationMultiSelector.ts Removes super.setValue(value) call (was the only caller of executeAction)
src/helpers/Association/AssociationSingleSelector.ts Removes super.setValue(value)
src/helpers/Association/utils.ts Removes onChangeEvent from extraction tuple
src/helpers/Database/DatabaseSingleSelectionSelector.ts Removes onChangeEvent, _valuesIsEqual guard, and executeAction call
src/helpers/Database/utils.ts Removes onChangeEvent from ExtractionReturnValue
src/helpers/EnumBool/EnumBoolSingleSelector.tsx Removes onChangeEvent field and executeAction call
src/helpers/Static/StaticSingleSelector.ts Removes onChangeEvent field and executeAction call
src/helpers/Static/utils.ts Removes onChangeEvent from extraction tuple
e2e/OnChange.spec.js New E2E spec covering all 6 source types + 1 fixme for known framework bug
e2e/utils/Combobox.pageObject.js New page object for combobox interaction
e2e/utils/logEntryParser.js New parser for change-tracking microflow log output
CHANGELOG.md Adds "improved reliability of On change action" under Unreleased / Fixed
docs/requirements/backend-structure.md Documents platform behaviour for onChange-bound actions
openspec/changes/archive/… Archived change artifacts (design, proposal, spec, tasks)

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


Findings

⚠️ Low — waitFrames(page, 10) is a frame-count timing wait

File: e2e/OnChange.spec.js line 127
Note: waitFrames(page, 10) pauses for 10 render frames before reading the log text. It works in practice but is fragile under load — if the microflow takes longer than expected the assertion can see stale output. A web-first assertion on the text widget first would make this resilient:

async function getLogs(page) {
    // wait for at least one log entry to appear before reading
    await expect(page.locator(".mx-name-text2")).not.toBeEmpty();
    const text = await page.locator(".mx-name-text2").innerText();
    return parseLogEntries(text);
}

Not blocking — waitFrames is used elsewhere in the repo and works — but worth improving before adding more tests that rely on this helper.


⚠️ Low — logEntryParser.js comment says "comma-separated" but the separator is !

File: e2e/utils/logEntryParser.js line 279
Note: The JSDoc above LIST_FIELDS reads "Field names whose raw value is a comma-separated list" but coerceListValue splits on "!". The block comment earlier in the file correctly describes the !-prefix format. A one-word fix prevents confusion for anyone reading just the inline JSDoc.

/** Field names whose raw value is a "!"-separated list (multi-relation). */
const LIST_FIELDS = new Set(["multiAssocTitles"]);

Positives

  • test.describe.fixme used correctly to quarantine the known-broken "pass association to onChange" test — the bug is in the framework, not the widget, and the comment explains why.
  • docs/requirements/backend-structure.md updated in the same PR to document the platform behaviour, so future reviewers won't mistake the absent onChangeEvent prop for a typings sync issue.
  • The _valuesIsEqual guard removal is explicitly justified in the design doc — the platform already deduplicates by value, so the guard was dead code.
  • Boilerplate executeAction calls cleanly removed from every selector in one shot; the openspec change documents each touched file, making the scope easy to audit.
  • CHANGELOG entry is user-facing and accurate ("reliability of On change action") without exposing internal refactoring details.

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.

3 participants