From c8d5e6e5a3405dafa4c7cb247387c8ea49de7c73 Mon Sep 17 00:00:00 2001 From: haoku123 Date: Fri, 14 Aug 2026 15:07:31 +0800 Subject: [PATCH] fix(Cell): restore clickable behavior when to or url prop is set v4.10.0 (#13846) changed onClick to only bind when clickable is true, but the clickable computation only considered the clickable and isLink props. Cells that relied on the implicit clickable behavior of the to / url props (working since before v4.10.0) stopped routing. Include to / url in the clickable computation while keeping the explicit clickable={false} opt-out. Fixes #13868 --- packages/vant/src/cell/Cell.tsx | 6 +++++- packages/vant/src/cell/test/index.spec.ts | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/vant/src/cell/Cell.tsx b/packages/vant/src/cell/Cell.tsx index bcb8d3802b2..5bebb513f03 100644 --- a/packages/vant/src/cell/Cell.tsx +++ b/packages/vant/src/cell/Cell.tsx @@ -146,7 +146,11 @@ export default defineComponent({ return () => { const { tag, size, center, border, isLink, required } = props; - const clickable = props.clickable ?? isLink; + // `to` / `url` props imply clickable behavior (same as before v4.10.0), + // so Cells with a route target keep working without an explicit `clickable` prop. + const clickable = Boolean( + props.clickable ?? props.to ?? props.url ?? isLink, + ); const classes: Record = { center, diff --git a/packages/vant/src/cell/test/index.spec.ts b/packages/vant/src/cell/test/index.spec.ts index e9a9809df77..4719d05a817 100644 --- a/packages/vant/src/cell/test/index.spec.ts +++ b/packages/vant/src/cell/test/index.spec.ts @@ -107,6 +107,27 @@ test('should not render as button when clickable is false with is-link prop', () expect(root.attributes('tabindex')).toBeFalsy(); }); +test('should be clickable when only to prop is set (regression #13868)', () => { + const wrapper = mount(Cell, { + props: { + to: '/foo', + }, + }); + expect(wrapper.classes()).toContain('van-cell--clickable'); + const root = wrapper.find('.van-cell'); + expect(root.attributes('role')).toEqual('button'); + expect(root.attributes('tabindex')).toEqual('0'); +}); + +test('should be clickable when only url prop is set (regression #13868)', () => { + const wrapper = mount(Cell, { + props: { + url: 'https://example.com', + }, + }); + expect(wrapper.classes()).toContain('van-cell--clickable'); +}); + test('should render tag prop correctly', () => { const wrapper = mount(Cell, { props: {