Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/vant/src/cell/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, boolean | undefined> = {
center,
Expand Down
21 changes: 21 additions & 0 deletions packages/vant/src/cell/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading