Skip to content

feat(Toast): allow action without dismissing toast#2673

Open
yan-ad wants to merge 1 commit into
unovue:v2from
yan-ad:fix/toast-action-optional-close
Open

feat(Toast): allow action without dismissing toast#2673
yan-ad wants to merge 1 commit into
unovue:v2from
yan-ad:fix/toast-action-optional-close

Conversation

@yan-ad
Copy link
Copy Markdown
Contributor

@yan-ad yan-ad commented Jun 3, 2026

🔗 Linked issue

Resolves #2626

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adds a closeOnClick prop to ToastAction so action buttons can run without always dismissing their toast. The default remains true, preserving the existing dismiss-on-click behavior.

This also documents the new prop and adds a regression test covering closeOnClick: false keeping the toast open after clicking the action.

📸 Screenshots (if appropriate)

N/A

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Added closeOnClick prop to toast actions to control whether toast dismisses when action is triggered.
  • Changes

    • ToastAction now renders as a button by default instead of a div.
  • Documentation

    • Enhanced Toast documentation with Vue examples and clarified action dismissal behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a closeOnClick prop to ToastAction to optionally prevent toast dismissal when an action is clicked. By default (closeOnClick={true}), the existing behavior is preserved. When closeOnClick={false}, the action runs without closing the toast.

Changes

ToastAction closeOnClick feature

Layer / File(s) Summary
ToastAction prop and conditional rendering
packages/core/src/Toast/ToastAction.vue, docs/content/meta/ToastAction.md
ToastAction declares an optional closeOnClick?: boolean prop (default true). The template conditionally renders ToastClose when closeOnClick is enabled; otherwise it renders a Primitive directly with conditional type="button". Component metadata documents the new prop and updates the default as element from "div" to "button".
Test coverage and user guide
packages/core/src/Toast/Toast.test.ts, docs/content/docs/components/toast.md
ToastWithPersistentAction test component renders a toast with closeOnClick: false, and a test verifies clicking the action increments a counter without closing the toast. A new Vue example in the user guide demonstrates using :close-on-click="false" with a retry action handler.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A toast that won't dismiss,
When actions call upon the kiss,
Persist and dance, no longer shy—
Let handlers run and by they fly! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the ability for Toast actions to run without dismissing the toast.
Linked Issues check ✅ Passed The PR fully implements the requested feature from issue #2626 by adding a closeOnClick prop that prevents automatic toast dismissal when action buttons are clicked.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the closeOnClick feature for Toast actions; no unrelated modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2673

commit: 0446c76

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 `@docs/content/docs/components/toast.md`:
- Around line 142-154: The keyboard-interaction docs incorrectly state that
ToastAction always closes on Space/Enter; update the keyboard table and any
related text to qualify that closing on Space/Enter is conditional on the prop
closeOnClick being true. Locate mentions of ToastAction and the keyboard table
in this doc (references: ToastAction, closeOnClick) and change the wording to
something like "closes on Space/Enter when closeOnClick === true" or equivalent
concise phrasing so the docs consistently reflect the conditional behavior.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d67d0a50-1ec0-455c-a938-42671e607cc2

📥 Commits

Reviewing files that changed from the base of the PR and between 091d650 and 0446c76.

📒 Files selected for processing (4)
  • docs/content/docs/components/toast.md
  • docs/content/meta/ToastAction.md
  • packages/core/src/Toast/Toast.test.ts
  • packages/core/src/Toast/ToastAction.vue

Comment on lines +142 to +154
By default, clicking `ToastAction` dismisses the toast. Set `closeOnClick` to `false` when the action should run while keeping the toast visible.

```vue
<template>
<ToastAction
alt-text="Retry sending the message"
:close-on-click="false"
@click="retry"
>
Retry
</ToastAction>
</template>
```
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update keyboard-interaction docs to reflect conditional close behavior.

Line 142 correctly introduces closeOnClick, but the keyboard table still says ToastAction always closes on Space/Enter. Please qualify that behavior as conditional (closeOnClick === true) to avoid conflicting guidance.

🤖 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 `@docs/content/docs/components/toast.md` around lines 142 - 154, The
keyboard-interaction docs incorrectly state that ToastAction always closes on
Space/Enter; update the keyboard table and any related text to qualify that
closing on Space/Enter is conditional on the prop closeOnClick being true.
Locate mentions of ToastAction and the keyboard table in this doc (references:
ToastAction, closeOnClick) and change the wording to something like "closes on
Space/Enter when closeOnClick === true" or equivalent concise phrasing so the
docs consistently reflect the conditional behavior.

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.

[Feature]: Action button should not always close Toast

1 participant