fix(toast): close button now dismisses on click — upgrade sonner v1.7 to v2 (#52)
User report: the toast close button (×) was visible on both desktop and mobile, but clicking/tapping it didn't dismiss the toast. Reading sonner v1.7.4's bundled source, the toast root attaches an `onPointerDown` that calls `r.target.setPointerCapture(r.pointerId)` unconditionally whenever the toast is dismissible. Combined with React 19's new event delegation (root-attached listeners instead of document-wide), this pointer capture quirk swallows the synthetic click event on the close button — so the bundled handler that calls `dismiss()` never runs. The bug fires on both mouse and touch because the PointerEvent capture is API-unified. Upgrade sonner from ^1.7.0 to ^2.0.7. Sonner v2 rewrote the pointer/swipe handling and ships first-class React 19 support; the close-button click now fires reliably on both desktop and mobile. The seven `toast.success/warning/ error/info` usage sites and the `<Toaster>` props (`position`, `theme`, `richColors`, `closeButton`, `toastOptions.classNames`) are API-compatible between v1 and v2 — typecheck and the 193 unit tests pass without changes. Bonus: add a `::after` hit-area expansion on `[data-close-button]` (visible size stays at sonner's 20px default; effective tap target ~36–40px) plus `touch-action: manipulation` to eliminate the 300ms tap delay on touch devices. Defensive — sonner v2 already fixes the underlying click issue, but the larger hit target is a free mobile UX win. Also adds: - `docs/tested-viewports.md` — the manual device test matrix the maintainer has been verifying against (BlackBerry Z30 / Galaxy S9+ / Pixel 3/4/7 / iPhone SE/12/14 Pro/XR/Pro Max / iPad / BlackBerry PlayBook). Documents the Nokia Lumia 520 (320x533) as a known limitation below the recommended minimum 360x640. - README EN + VI link to the new doc. - THIRD-PARTY.md bumps sonner version 1.7 to 2.0.7. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
25cac76373
commit
a6caa88d9c
7 files changed
+74
-8
No files matched your search
@@ -42,7 +42,7 @@ JSONPrism is a refracting tool for developers. It takes a single JSON input and
|
||||
- **Smart shape detection** — recognizes flat objects, arrays of objects, scalars; suggests the best target format.
|
||||
- **Per-format options** — pretty-print, indentation, dialect (for SQL), alignment (for Markdown), and more.
|
||||
- **Dark + light themes** — Prism Spectrum palette with violet / cyan / amber / rose accents.
|
||||
- **Responsive — designed for viewports ≥ 360 × 640.** Smaller screens still work but may feel cramped; on mobile, Input and Output use a Tabs UI to give each panel full height.
|
||||
- **Responsive — designed for viewports ≥ 360 × 640.** Smaller screens still work but may feel cramped; on mobile, Input and Output use a Tabs UI to give each panel full height. See [`docs/tested-viewports.md`](docs/tested-viewports.md) for the full device test matrix.
|
||||
- **EN + VI** — bilingual interface out of the box. More languages welcome.
|
||||
- **Tauri desktop build** — drag-and-drop file workflow, offline-first (Phase 2 milestone).
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ JSONPrism là công cụ "tán sắc" cho developer. Nhận một JSON đầu v
|
||||
- **Phát hiện shape thông minh** — nhận diện flat object, mảng object, scalar; gợi ý format đích phù hợp.
|
||||
- **Tuỳ chọn theo từng format** — pretty-print, indentation, dialect (SQL), alignment (Markdown), v.v.
|
||||
- **Theme sáng/tối** — bảng màu Prism Spectrum với violet / cyan / amber / rose.
|
||||
- **Responsive — tối ưu cho viewport ≥ 360 × 640.** Màn hình nhỏ hơn vẫn dùng được nhưng có thể chật; trên mobile, Input và Output dùng Tabs UI để mỗi panel có toàn bộ chiều cao.
|
||||
- **Responsive — tối ưu cho viewport ≥ 360 × 640.** Màn hình nhỏ hơn vẫn dùng được nhưng có thể chật; trên mobile, Input và Output dùng Tabs UI để mỗi panel có toàn bộ chiều cao. Xem [`docs/tested-viewports.md`](docs/tested-viewports.md) cho ma trận thiết bị đã kiểm thử.
|
||||
- **Đa ngôn ngữ EN + VI** — sẵn sàng từ ngày đầu. Hoan nghênh thêm ngôn ngữ khác.
|
||||
- **Bản desktop Tauri** — drag-and-drop file, hoạt động offline (mốc Phase 2).
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ the relevant notices. This file is a starting point.
|
||||
| `@radix-ui/react-switch` | ^1.1.0 | MIT | [radix-ui.com](https://www.radix-ui.com/) |
|
||||
| `@radix-ui/react-tabs` | ^1.1.0 | MIT | [radix-ui.com](https://www.radix-ui.com/) |
|
||||
| `lucide-react` | ^0.460.0 | ISC | [lucide.dev](https://lucide.dev/) |
|
||||
| `sonner` | ^1.7.0 | MIT | [sonner.emilkowal.ski](https://sonner.emilkowal.ski/) |
|
||||
| `sonner` | ^2.0.7 | MIT | [sonner.emilkowal.ski](https://sonner.emilkowal.ski/) |
|
||||
| `react-dropzone` | ^14.3.0 | MIT | [react-dropzone.js.org](https://react-dropzone.js.org/) |
|
||||
|
||||
The component patterns under `src/components/ui/` are generated from
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# Tested viewports
|
||||
|
||||
JSONPrism's mobile and tablet rendering is verified across the devices below.
|
||||
|
||||
Status legend:
|
||||
|
||||
- ✅ Works as expected
|
||||
- ⚠️ Cramped but functional
|
||||
- ❌ Known limitation (typically below recommended minimum)
|
||||
|
||||
Recommended minimum viewport: **360 × 640**. Phones in landscape orientation are best-effort — see [recommendation](#recommendation).
|
||||
|
||||
## Test results (last verified 2026-05-14)
|
||||
|
||||
### Phones (portrait)
|
||||
|
||||
| Device | Viewport | Status | Notes |
|
||||
| ------------------------------------------------ | --------- | ------ | ------------------------------ |
|
||||
| BlackBerry Z30 / Samsung Galaxy Note 3 / Nexus 5 | 360 × 640 | ✅ | Minimum recommended viewport |
|
||||
| Samsung Galaxy S9+ | 320 × 658 | ✅ | Below recommended width, works |
|
||||
| Pixel 4 | 353 × 745 | ✅ | |
|
||||
| Pixel 3 | 393 × 786 | ✅ | |
|
||||
| iPhone SE (2nd/3rd gen) | 375 × 667 | ✅ | |
|
||||
| iPhone 12 Pro | 390 × 844 | ✅ | |
|
||||
| iPhone 14 Pro | 393 × 852 | ✅ | Verified on real device |
|
||||
| iPhone XR | 414 × 896 | ✅ | |
|
||||
| Pixel 7 | 412 × 915 | ✅ | |
|
||||
| iPhone 14 Pro Max | 420 × 932 | ✅ | |
|
||||
|
||||
### Tablets
|
||||
|
||||
| Device | Viewport | Status | Notes |
|
||||
| ------------------- | ---------- | ------ | -------------------------------------------------- |
|
||||
| BlackBerry PlayBook | 600 × 1024 | ✅ | |
|
||||
| iPad | 768 × 1024 | ✅ | Side-by-side input/output kicks in at `md` (768px) |
|
||||
|
||||
### Known limitations
|
||||
|
||||
| Device | Viewport | Status | Notes |
|
||||
| -------------- | --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Nokia Lumia 520 | 320 × 533 | ❌ | Code editor disappears — viewport is below the recommended minimum height (640). Worth revisiting in a future round if demand surfaces. |
|
||||
|
||||
## Recommendation
|
||||
|
||||
- **Portrait orientation only on phones.** Landscape on phones (height < width) compresses each tab's content area to ~150–200px after chrome and is best-effort.
|
||||
- **Below recommended minimum (360 × 640)**: layout is functional but the code editor may collapse on very short heights (< 600px).
|
||||
|
||||
## How to retest
|
||||
|
||||
1. Open Chrome DevTools → "Toggle device toolbar" (Ctrl+Shift+M).
|
||||
2. Pick a device from the dropdown or set a custom viewport.
|
||||
3. Verify on the Home page: Header navigation visible, Input/Output Tabs accessible, FormatPicker trigger fits, no horizontal scroll on `<body>`.
|
||||
|
||||
Test results contributed by the maintainer. PRs welcome to expand the matrix.
|
||||
Generated
+4
-4
@@ -48,7 +48,7 @@
|
||||
"react-i18next": "^15.0.0",
|
||||
"react-router-dom": "^7.0.0",
|
||||
"smol-toml": "^1.3.0",
|
||||
"sonner": "^1.7.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^2.5.0",
|
||||
"zustand": "^5.0.0"
|
||||
},
|
||||
@@ -5603,9 +5603,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/sonner": {
|
||||
"version": "1.7.4",
|
||||
"resolved": "https://registry.npmjs.org/sonner/-/sonner-1.7.4.tgz",
|
||||
"integrity": "sha512-DIS8z4PfJRbIyfVFDVnK9rO3eYDtse4Omcm6bt0oEr5/jtLgysmjuBl1frJ9E/EQZrFmKx2A8m/s5s9CRXIzhw==",
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/sonner/-/sonner-2.0.7.tgz",
|
||||
"integrity": "sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@
|
||||
"react-i18next": "^15.0.0",
|
||||
"react-router-dom": "^7.0.0",
|
||||
"smol-toml": "^1.3.0",
|
||||
"sonner": "^1.7.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^2.5.0",
|
||||
"zustand": "^5.0.0"
|
||||
},
|
||||
|
||||
@@ -198,4 +198,16 @@
|
||||
)
|
||||
1;
|
||||
}
|
||||
|
||||
/* Expand the Sonner close-button hit-test radius for touch.
|
||||
Visible size stays at sonner's 20px default; the ::after pseudo
|
||||
gives an effective ~36–40px tap target without changing layout. */
|
||||
[data-sonner-toaster] [data-close-button] {
|
||||
touch-action: manipulation;
|
||||
}
|
||||
[data-sonner-toaster] [data-close-button]::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -8px;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user