Skip to content

[WC-3501]: fix(combobox-web): fix inverted editability logic#2332

Open
r0b1n wants to merge 2 commits into
mainfrom
fix/combobox-editability-inverted
Open

[WC-3501]: fix(combobox-web): fix inverted editability logic#2332
r0b1n wants to merge 2 commits into
mainfrom
fix/combobox-editability-inverted

Conversation

@r0b1n

@r0b1n r0b1n commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed a bug in getReadonly() where the conditionally editability mode had inverted logic: expression.value = true (meaning "editable") was being returned directly as the read-only flag, making the widget read-only when it should be editable, and vice versa.
  • Fixed a related bug where the presence of an editable targetAttribute caused the function to return early with false (editable), bypassing the custom editability condition entirely. Now targetAttribute only short-circuits when it is explicitly read-only.
  • Added unit tests covering all branches of getReadonly.

Root cause

Two issues in getReadonly:

  1. The original early-return on targetAttribute presence meant any editable attribute would always report the widget as editable, ignoring the never or conditionally settings.
  2. The conditionally branch returned customEditabilityExpression.value ?? true directly, where the expression represents editability (true = editable), so the boolean was inverted.

The `conditionally` branch returned `expression.value` directly, so a
truthy value (meaning "editable") made the widget read-only, and vice
versa.  Fixed by returning `true` only when the expression is not `true`,
and added unit tests for all `getReadonly` branches.
@r0b1n r0b1n requested a review from a team as a code owner July 16, 2026 09:04
@github-actions

This comment has been minimized.

@r0b1n r0b1n changed the title fix(combobox-web): fix inverted editability logic [WC-3501] fix(combobox-web): fix inverted editability logic Jul 16, 2026
@r0b1n r0b1n changed the title [WC-3501] fix(combobox-web): fix inverted editability logic [WC-3501]: fix(combobox-web): fix inverted editability logic Jul 16, 2026
- Split "loading or unavailable" test cases into separate loading and
  unavailable variants to make coverage explicit
- Add changelog entry for the attribute-presence bug that bypassed
  custom editability conditions
@r0b1n r0b1n force-pushed the fix/combobox-editability-inverted branch from aecac76 to 2351483 Compare July 16, 2026 13:02
@github-actions

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/helpers/Database/utils.ts Fixed inverted getReadonly logic: attribute early-return now only short-circuits on readOnly, and conditionally branch correctly negates the expression
packages/pluggableWidgets/combobox-web/src/helpers/Database/__tests__/utils.spec.ts New test file covering all branches of getReadonly
packages/pluggableWidgets/combobox-web/CHANGELOG.md Unreleased entries added for both fixes plus a breaking-change note

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

CI checks could not be retrieved (permission denied); please confirm they are green before merging.


Findings

⚠️ Low — Non-standard CHANGELOG section name

File: packages/pluggableWidgets/combobox-web/CHANGELOG.md line 17
Note: Keep a Changelog defines six standard section names: Added, Changed, Deprecated, Removed, Fixed, Security. ### Breaking changes is not one of them and may not render correctly with automated changelog tooling. Consider folding the breaking-change note into ### Changed or appending it as a callout under the ### Fixed entry.


Positives

  • The two-line logic fix is minimal and precise — targetAttribute?.readOnly and !== true each address exactly one bug without touching unrelated code paths.
  • Test coverage is comprehensive: all three targetAttribute states (read-only, editable, undefined) × all three customEditability modes × all three DynamicValue states (available/true, available/false, loading, unavailable) are explicitly exercised.
  • EditableValueBuilder and dynamic helpers from @mendix/widget-plugin-test-utils are used correctly throughout — no manual mock objects.
  • Safe-by-default for loading/unavailable expressions: value !== true correctly treats undefined as read-only without needing an explicit null-check branch.

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