Skip to content
Merged
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
8 changes: 4 additions & 4 deletions examples/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const addressOptions = [
children: [],
},
{
label: '福建',
value: 'fj',
label: '福建 "',
value: 'fj "',
title: '测试标题',
children: [
{
label: '福州',
value: 'fuzhou',
label: '福州"',
value: 'fuzhou "',
children: [
{
label: '马尾',
Expand Down
4 changes: 3 additions & 1 deletion src/OptionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ const RefOptionList = React.forwardRef<RefOptionListProps>((props, ref) => {
for (let i = 0; i < activeValueCells.length; i += 1) {
const cellPath = activeValueCells.slice(0, i + 1);
const cellKeyPath = toPathKey(cellPath);
const ele = containerRef.current?.querySelector(`li[data-path-key="${cellKeyPath}"]`);
const ele = containerRef.current?.querySelector(
`li[data-path-key="${cellKeyPath.replace(/(?<!\\)"/g, '\\"')}"]`, // matches unescaped double quotes
);
ele?.scrollIntoView?.({ block: 'nearest' });
}
}, [activeValueCells]);
Expand Down
28 changes: 25 additions & 3 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable react/jsx-no-bind */

import React from 'react';
import { resetWarned } from 'rc-util/lib/warning';
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
import { mount } from './enzyme';
import { resetWarned } from 'rc-util/lib/warning';
import React from 'react';
import Cascader from '../src';
import { addressOptions, optionsForActiveMenuItems } from './demoOptions';
import { mount } from './enzyme';

describe('Cascader.Basic', () => {
let selectedValue;
Expand Down Expand Up @@ -806,4 +806,26 @@ describe('Cascader.Basic', () => {
wrapper.unmount();
});
});

it('should support double quote in label and value', () => {
const wrapper = mount(
<Cascader
options={[
{
label: 'bamboo "',
value: 'bamboo "',
children: [
{
label: 'bamboo2 "',
value: 'bamboo2 "',
},
],
},
]}
open
/>,
);

wrapper.find(`li[data-path-key]`).simulate('click');
});
});