Skip to content

Commit

Permalink
fix: 修改Cascade的修复现实children的bug (#2165)
Browse files Browse the repository at this point in the history
* fix: 修改Cascade的修复现实children的bug

* fix: 修改名称拼写错误
  • Loading branch information
Ryan Zhang authored Jul 4, 2023
1 parent 9e20078 commit b8df5a8
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 285 deletions.
2 changes: 1 addition & 1 deletion src/cascader/demos/Cascader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CascaderProps } from '../interface';
import Cascader from '../Cascader';
import '../style';
import './style.less';
import CascaderItem from '../../list/inner/CascaderItem';
import CascaderItem from '../../list/inner/CascadeItem';
import Docs from './CascaderPage';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/cascader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CascaderItem from '../list/inner/CascaderItem';
import CascaderItem from '../list/inner/CascadeItem';
import WithSubComponent from '../utils/withSubComponent';
import Cascader from './Cascader';

Expand Down
2 changes: 1 addition & 1 deletion src/dropdown/demos/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import '../style';
import Button from '../../button';
import List from '../../list';
import Divider from '../../divider';
import CascaderItem from '../../list/inner/CascaderItem';
import CascaderItem from '../../list/inner/CascadeItem';
import { PopConfirm } from '../..';

export default {
Expand Down
9 changes: 5 additions & 4 deletions src/list/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React, { useContext } from 'react';
import { ItemProps } from './interface';
import BaseItem from './inner/baseItem';
import CheckboxItem from './inner/CheckboxItem';
import CalcaderItem from './inner/CascaderItem';
import CascadeItem from './inner/CascadeItem';
import WithRef from '../utils/withRef';
import { ListContext } from './context';

export const InnerItem = WithRef<HTMLLIElement, ItemProps>((props, ref?) => {
const { label, value, disabled, strategy, ...rest } = props;
const { label, value, disabled, strategy, items, ...rest } = props;
const { model } = useContext(ListContext);

const defaultProps = {
Expand All @@ -21,15 +21,16 @@ export const InnerItem = WithRef<HTMLLIElement, ItemProps>((props, ref?) => {
if (model === 'multiple') {
return <CheckboxItem data-testid="list-item-checkbox" {...defaultProps} />;
}
if (model === 'cascader') {
if (model === 'cascader' || model === 'cascade') {
return (
<CalcaderItem
<CascadeItem
ref={ref}
data-testid="list-item-cascader"
label={label as string}
value={value as string}
disabled={disabled}
strategy={strategy}
items={items as any}
{...rest}
/>
);
Expand Down
9 changes: 8 additions & 1 deletion src/list/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ export const InnerList = WithRef<HTMLDivElement, ListProps>((props, ref?) => {
const renderChildren = (option: OptionProps) => {
const renderedItem = renderItem?.(option);
return (
<Item prefix={prefix?.(option)} suffix={suffix?.(option)} {...option} strategy={itemStrategy} key={option.value}>
<Item
prefix={prefix?.(option)}
suffix={suffix?.(option)}
{...option}
items={option?.children as OptionProps[]}
strategy={itemStrategy}
key={option.value}
>
{renderedItem}
</Item>
);
Expand Down
Loading

1 comment on commit b8df5a8

@vercel
Copy link

@vercel vercel bot commented on b8df5a8 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gio-design – ./

gio-design-git-master-growingio.vercel.app
gio-design-growingio.vercel.app
gio-design.vercel.app

Please sign in to comment.