Skip to content

fix: close UIKit modal when viewSubmit returns success with no type f… - #7537

Open
erikurt9 wants to merge 3 commits into
RocketChat:developfrom
erikurt9:fix/uikit-modal-close-on-success-response
Open

fix: close UIKit modal when viewSubmit returns success with no type f…#7537
erikurt9 wants to merge 3 commits into
RocketChat:developfrom
erikurt9:fix/uikit-modal-close-on-success-response

Conversation

@erikurt9

@erikurt9 erikurt9 commented Aug 1, 2026

Copy link
Copy Markdown

Summary

Fixes #7503

When a Rocket.Chat App responds to a viewSubmit UIKit interaction with a bare success response ({ "success": true }, no type field), the modal now closes correctly instead of staying open silently.

Root Cause

In app/lib/methods/actions.ts, triggerAction() was passing interactionType ?? '' to toServerModalInteractionType(), which returns null for an empty string. This caused an error to be thrown and caught silently by ModalBlockView.submit()'s outer catch block, preventing Navigation.back() from ever being called.

Fix

Added an early return of ModalActions.CLOSE when interactionType is undefined, before consulting the allow-list. This restores the behavior that existed before PR #7057 for this specific case, without weakening the error thrown for genuinely unrecognized type strings.

const { type: interactionType, ...data } = parsed;
+ if (interactionType === undefined) {
+     return ModalActions.CLOSE;
+ }
const modalType = toServerModalInteractionType(interactionType);
if (!modalType) {
-   throw new Error(`Unknown modal interaction type: ${interactionType ?? 'undefined'}`);
+   throw new Error(`Unknown modal interaction type: ${interactionType}`);
}

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of successful modal closures when the server response does not include an interaction type.
    • Preserved clear error reporting for unsupported interaction types.
    • Ensured trigger data continues to be cleaned up reliably after actions complete.

…ield

When a Rocket.Chat App responds to a viewSubmit interaction with a bare
success response ({ success: true }, no type field), the modal now closes
correctly instead of throwing an unhandled error that gets swallowed silently.

Fixes RocketChat#7503
@CLAassistant

CLAassistant commented Aug 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d050d753-b0e6-4aa7-96ca-5eb4055c2682

📥 Commits

Reviewing files that changed from the base of the PR and between 140a44e and 53015c9.

📒 Files selected for processing (1)
  • app/lib/methods/actions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/lib/methods/actions.ts

Walkthrough

triggerAction now closes the modal when a server response omits the interaction type. Known interaction types retain their existing handling. Unknown interaction types still raise an error. Trigger-ID cleanup remains in the finally block.

Changes

Modal response handling

Layer / File(s) Summary
Process modal response types
app/lib/methods/actions.ts
Responses without an interaction type return ModalActions.CLOSE. Known types continue through conversion, and unknown types still raise an error. Trigger-ID invalidation remains in finalization.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the UIKit modal fix for successful viewSubmit responses without a type field.
Linked Issues check ✅ Passed The change satisfies #7503 by closing modals for missing types while preserving errors for unrecognized interaction type strings.
Out of Scope Changes check ✅ Passed The changes are limited to the triggerAction response handling required by #7503.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/lib/methods/actions.ts`:
- Line 177: Add the missing trailing newline after the final closing brace in
the file. Then run pnpm prettier-lint and TZ=UTC pnpm test for the modified
files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fad29f0c-e4f0-4c63-9f84-6f1fe8a60610

📥 Commits

Reviewing files that changed from the base of the PR and between 6f9a093 and 313aa06.

📒 Files selected for processing (1)
  • app/lib/methods/actions.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions

Files:

  • app/lib/methods/actions.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbers

Files:

  • app/lib/methods/actions.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{js,jsx,ts,tsx}: Before committing changes to JavaScript or TypeScript files, run pnpm prettier-lint and TZ=UTC pnpm test for the modified files.
Use the local-first data flow: the UI reads from WatermelonDB, while sagas synchronize data with the server.
Use Redux and Redux-Saga for global or server state, and use Zustand for feature-local stores; do not assume all state is in Redux.

Files:

  • app/lib/methods/actions.ts
🧠 Learnings (1)
📚 Learning: 2026-04-30T17:07:51.020Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7274
File: app/lib/services/voip/MediaCallEvents.ts:0-0
Timestamp: 2026-04-30T17:07:51.020Z
Learning: In this Rocket.Chat React Native codebase, the ESLint rule `no-void: error` is enforced. When you see a promise returned from an async call that is not awaited (a “floating promise”), do not silence it with the `void somePromise()` pattern. Instead, handle the promise explicitly by attaching `.catch(...)` (or otherwise awaiting/handling the error) so unhandled-rejection risks are addressed in a way that satisfies the existing ESLint configuration.

Applied to files:

  • app/lib/methods/actions.ts
🪛 ESLint
app/lib/methods/actions.ts

[error] 177-177: Insert

(prettier/prettier)

🔇 Additional comments (1)
app/lib/methods/actions.ts (1)

158-176: LGTM!

invalidateTriggerId(triggerId);
}
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the missing final newline.

Prettier reports Insert ⏎ at Line 177. Add a newline after the closing brace.

As per coding guidelines, run pnpm prettier-lint and TZ=UTC pnpm test for the modified files before committing.

🧰 Tools
🪛 ESLint

[error] 177-177: Insert

(prettier/prettier)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/lib/methods/actions.ts` at line 177, Add the missing trailing newline
after the final closing brace in the file. Then run pnpm prettier-lint and
TZ=UTC pnpm test for the modified files.

Sources: Coding guidelines, Linters/SAST tools

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@erikurt9

erikurt9 commented Aug 5, 2026

Copy link
Copy Markdown
Author

Please review already signed the CLA

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.

UIKit modal: a viewSubmit response with no type field fails to close the modal on mobile (regression from #7057)

2 participants