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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"test": "rc-test"
},
"dependencies": {
"@rc-component/select": "~1.2.0-alpha.2",
"@rc-component/select": "~1.2.0-alpha.3",
"@rc-component/tree": "~1.0.0",
"@rc-component/util": "^1.3.0",
"clsx": "^2.1.1"
Expand Down
22 changes: 11 additions & 11 deletions src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ export type GetOptionType<
Multiple extends boolean | React.ReactNode = false,
> = false extends Multiple ? OptionType[] : OptionType[][];

type SemanticName = 'input' | 'prefix' | 'suffix';
type SemanticName =
| 'input'
| 'prefix'
| 'suffix'
| 'placeholder'
| 'content'
| 'item'
| 'itemContent'
| 'itemRemove';
Comment on lines +155 to +163
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The SemanticName type definition has been expanded to include new semantic names. Ensure that all these names are consistently used throughout the component and that they cover all customizable elements. Also, consider adding documentation or comments to explain the purpose of each semantic name.

Missing documentation can lead to confusion and inconsistent usage.

type PopupSemantic = 'list' | 'listItem';
export interface CascaderProps<
OptionType extends DefaultOptionType = DefaultOptionType,
Expand Down Expand Up @@ -451,16 +459,8 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
prefixCls={prefixCls}
autoClearSearchValue={autoClearSearchValue}
popupMatchSelectWidth={popupMatchSelectWidth}
classNames={{
prefix: classNames?.prefix,
suffix: classNames?.suffix,
input: classNames?.input,
}}
styles={{
prefix: styles?.prefix,
suffix: styles?.suffix,
input: styles?.input,
}}
classNames={classNames}
styles={styles}
popupStyle={{
...popupStyle,
...customPopupStyle,
Expand Down
52 changes: 23 additions & 29 deletions tests/__snapshots__/search.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Cascader.Search should correct render Cascader with same field name of label and value 1`] = `
<div
class="rc-cascader rc-cascader-single rc-cascader-open rc-cascader-show-search"
>
[
<div
class="rc-cascader-selector"
class="rc-cascader rc-cascader-single rc-cascader-open rc-cascader-show-search"
>
<span
class="rc-cascader-selection-wrap"
<div
class="rc-cascader-content"
>
<span
class="rc-cascader-selection-search"
>
<input
aria-autocomplete="list"
aria-controls="test-id_list"
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="test-id_list"
autocomplete="off"
class="rc-cascader-selection-search-input"
id="test-id"
role="combobox"
type="search"
value="z"
/>
</span>
<span
class="rc-cascader-selection-placeholder"
<div
class="rc-cascader-placeholder"
style="visibility: hidden;"
/>
</span>
</div>
<input
aria-autocomplete="list"
aria-controls="test-id_list"
aria-expanded="true"
aria-haspopup="listbox"
aria-owns="test-id_list"
autocomplete="off"
class="rc-cascader-input"
id="test-id"
role="combobox"
type="search"
value="z"
/>
</div>
</div>,
<div
class="rc-cascader-dropdown rc-cascader-dropdown-placement-bottomLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
Expand Down Expand Up @@ -74,6 +68,6 @@ exports[`Cascader.Search should correct render Cascader with same field name of
</ul>
</div>
</div>
</div>
</div>
</div>,
]
`;
6 changes: 3 additions & 3 deletions tests/fieldNames.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Cascader.FieldNames', () => {
);

// Open
wrapper.find('.rc-cascader-selector').simulate('mousedown');
wrapper.find('.rc-cascader').first().simulate('mousedown');
expect(wrapper.isOpen()).toBeTruthy();

// Check values
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Cascader.FieldNames', () => {
/>,
);

expect(wrapper.find('.rc-cascader-selection-item').text()).toEqual('Bamboo / Little / Toy');
expect(wrapper.find('.rc-cascader-content-value').text()).toEqual('Bamboo / Little / Toy');

expect(wrapper.find('.rc-cascader-menu')).toHaveLength(3);
expect(wrapper.find('.rc-cascader-menu-item-active')).toHaveLength(3);
Expand All @@ -97,7 +97,7 @@ describe('Cascader.FieldNames', () => {
/>,
);

expect(wrapper.find('.rc-cascader-selection-item').text()).toEqual(
expect(wrapper.find('.rc-cascader-content-value').text()).toEqual(
'Bamboo->Little->Toy & bamboo>>little>>toy',
);
});
Expand Down
Loading
Loading