Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(list-pro): fix can't drag, update datasource state not synchronize, update style #1046

Merged
merged 1 commit into from
Jun 28, 2021
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
12 changes: 6 additions & 6 deletions src/components/config-provider/context.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import React, { useContext, forwardRef } from 'react';

import { SizeType } from './SizeContext';

Expand Down Expand Up @@ -58,16 +58,16 @@ interface ConstructorProps {
displayName?: string;
}
export function withConfigConsumer<ExportProps extends BasicExportProps>(config: ConsumerConfig) {
return function withConfigConsumerFunc<ComponentDef>(
return function withConfigConsumerFunc(
Component: IReactComponent
): React.FC<ExportProps> & ComponentDef {
): React.ForwardRefExoticComponent<React.PropsWithoutRef<ExportProps> & React.RefAttributes<unknown>> {
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
const SFC = ((props: ExportProps) => {
const SFC = forwardRef((props: ExportProps, ref) => {
const { subPrefixCls } = config;
const { rootPrefixCls, ...restConfigContext } = useContext(ConfigContext);
const prefixCls = getGioDesignPrefixCls(subPrefixCls, rootPrefixCls);
return <Component {...restConfigContext} {...props} prefixCls={prefixCls} />;
}) as React.FC<ExportProps> & ComponentDef;
return <Component {...restConfigContext} {...props} prefixCls={prefixCls} ref={ref} />;
}) as React.ForwardRefExoticComponent<React.PropsWithoutRef<ExportProps> & React.RefAttributes<unknown>>;

const cons: ConstructorProps = Component.constructor as ConstructorProps;
const name = cons?.displayName || Component.name || 'Component';
Expand Down
1 change: 1 addition & 0 deletions src/components/drawer/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface DrawerProps {
onNext?: () => void;
nextDisabled?: boolean;
loading?: boolean;
children?: React.ReactNode[] | React.ReactNode;
}

export interface IDrawerState {
Expand Down
5 changes: 1 addition & 4 deletions src/components/list-pro/Sortable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class SortableCollection extends React.PureComponent<SortableColl
if (state.stateChanged) {
return { ...state, stateChanged: false };
}
return { collection: nextProps.collection };
return { collections: nextProps.collection };
}

private _handleHover = (originalSourcePosition: number, originalTargetPosition: number) => {
Expand All @@ -50,9 +50,6 @@ export default class SortableCollection extends React.PureComponent<SortableColl
const currentSourcePosition = collections.indexOf(source);
const target = collection[originalTargetPosition];
const currentTargetPosition = collections.indexOf(target);
console.log('====================================');
console.log(collection);
console.log('====================================');
if (source) {
// eslint-disable-next-line react/no-access-state-in-setstate
const newCollection = [...collections];
Expand Down
4 changes: 2 additions & 2 deletions src/components/list-pro/Sortable/template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SiderSelectedItem extends React.PureComponent<SiderSelectedItemProps & Con
>
{get(item, 'canDrag') !== false && (
<IconCircle className={classnames({ selected: item.value === props.selected, collapsed: props.collapsed })}>
<DragMove className="icon-drag" />
<DragMove size='14px' className="icon-drag" />
</IconCircle>
)}

Expand All @@ -78,7 +78,7 @@ class SiderSelectedItem extends React.PureComponent<SiderSelectedItemProps & Con
})}
aria-hidden="true"
>
<CloseCircleFilled size="small" color="#5C4E61" />
<CloseCircleFilled size="14px" color="#313E75" />
</span>
</div>
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/list-pro/drag.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { unionBy, noop } from 'lodash';
import usePrefixCls from '../../utils/hooks/use-prefix-cls';
import Sortable from './Sortable';
Expand All @@ -19,6 +19,10 @@ const DragableList = ({
const prefixCls = usePrefixCls('list', customPrefixCls);
const [data, setData] = useState(dataSource);

useEffect(() => {
setData(dataSource);
}, [dataSource])

const innerHandleSort = (steps: any) => {
const combineDashbord = unionBy(steps, dataSource, 'value');
if (handleSort) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/list-pro/option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SelectOption = (props: OptionProps) => {
{isMultiple && !allowDuplicate && (
<>
<Checkbox checked={isSelected} disabled={disabled} onChange={noop} />
<span style={{ width: 10 }} />
<span style={{ width: 8 }} />
</>
)}
{props.children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/list-pro/style/option.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.@{select-prefix-cls}-option {
box-sizing: border-box;
max-width: 100%;
padding: 0 25px 0 16px;
padding: 0 25px 0 12px;
overflow: hidden;
color: @color-font-list-primary-normal;
font-size: 14px;
Expand Down
22 changes: 12 additions & 10 deletions src/components/list-pro/style/sort.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
@icon-circle-color-light: #f1f1fa;
@icon-circle-color-text: #220968;

.@{list-prefix-cls}-wrapper:hover .icon-drag {
display: inline-block;
}

.pa_sider-selected-item {
position: relative;
display: flex;
align-items: center;
height: 40px;
padding-left: 20px;
height: 36px;
padding-left: 34px;
color: @color-font-list-primary-normal;
font-size: 14px;
line-height: 40px;
line-height: 36px;
background: white;
cursor: pointer;
transition: background-color 0.3s ease;
Expand All @@ -24,8 +28,7 @@
&__name-wrap {
position: relative;
display: inline-block;
height: 40px;
padding-left: 4px;
height: 36px;
}

&__name {
Expand Down Expand Up @@ -99,7 +102,7 @@
right: 10px;
display: none;
width: 12px;
height: 40px;
height: 36px;
&.collapsed {
display: none;
}
Expand All @@ -108,12 +111,11 @@

.pa-sider-icon-circle {
position: absolute;
left: 2px;
left: 12px;
display: inline-block;
width: 24px;
height: 24px;
line-height: 23px;
line-height: 24px;
text-align: center;
transform: rotate(90deg);
cursor: move;

&.hollow {
Expand Down
1 change: 1 addition & 0 deletions src/components/tree-select/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class TreeSelect<T> extends React.Component<TreeSelectProps<T>> {
switcherIcon={(nodeProps: GioTreeNodeProps) => renderSwitcherIcon(treePrefixCls, switcherIcon, nodeProps)}
showTreeIcon={false}
showSearch
treeNodeFilterProp='title'
notFoundContent={mergedNotFound}
getPopupContainer={getPopupContainer || getContextPopupContainer}
treeMotion={null}
Expand Down
2 changes: 1 addition & 1 deletion src/components/tree-select/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
text-transform: none;
background: ghostwhite;
cursor: pointer;
opacity: 1;
opacity: 0;
transition: color 0.3s ease, opacity 0.15s ease;
text-rendering: auto;

Expand Down