Skip to content

fix(ui-kit): preserve falsy values in getInitialValue and useUiKitState - #1436

Open
swarnendusahu10-dotcom wants to merge 1 commit into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/issue-1235-uikit-falsy-initial-values
Open

swarnendusahu10-dotcom wants to merge 1 commit into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/issue-1235-uikit-falsy-initial-values

Conversation

@swarnendusahu10-dotcom

Copy link
Copy Markdown
Contributor

Summary

Fixes #1235 by ensuring that valid falsy values (0, "", false) are preserved during initial value extraction and UI Kit state resolution.

Details

  1. useUiKitState.js: Replaced (values && (values[actionId]?.value || initialValue)) ?? initialValue with values?.[actionId]?.value ?? initialValue. The logical OR (||) was inadvertently replacing valid falsy values (like 0 or false) with initialValue.
  2. getInitialValue.js: Replaced the chained short-circuiting expression (&& / ||) with explicit property guard clauses. This prevents valid initialValue: 0 or initialValue: false from falling through to subsequent property checks or returning undefined.

Verification

  • Verified initialValue: 0, initialValue: false, and initialValue: "" correctly return the falsy value instead of falling through to undefined.
  • Verified values[actionId].value = 0 retains 0 and does not fall back to initialValue.
  • Verified fallback to initialValue still occurs when value is null or undefined.
  • @embeddedchat/ui-kit builds cleanly with rollup -c.
  • Zero merge conflicts against latest develop.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI Kit falsy values are lost in initial/state resolution for block elements

1 participant