Skip to content

Commit

Permalink
fix: 修复 table 的 column 的 id 属性可能重复导致样式错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Dec 20, 2023
1 parent e9a0d24 commit 45379eb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
12 changes: 11 additions & 1 deletion packages/amis-core/src/store/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,14 +1159,24 @@ export const TableStore = iRendererStore
});

const originColumns = self.columns.concat();
const ids: Array<any> = [];
columns = columns.map((item, index) => {
const origin = item.id
? originColumns.find(column => column.pristine.id === item.id)
: originColumns[index];

let id = origin?.id || guid();

// 还不知道为何会出现这个,先用这种方式避免 id 重复
if (ids.includes(id)) {
id = guid();
}

ids.push(id);

return {
...item,
id: origin?.id || guid(),
id: id,
index,
width: origin?.width || 0,
minWidth: origin?.minWidth || 0,
Expand Down
5 changes: 2 additions & 3 deletions packages/amis-ui/scss/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,6 @@
--inputTag-option-hover-bg-color: var(--colors-brand-10);
--inputTag-popover-maxHeight: 300px;


--fieldSet-legend-height: var(--sizes-size-9);
--fieldSet-legend-color: var(--colors-neutral-text-2);
--fieldSet-legend-fontSize: var(--fonts-size-7);
Expand Down Expand Up @@ -3919,9 +3918,9 @@
--conditionBuilder-line-width: var(--sizes-size-2);
--conditionBuilder-line-bg-color: var(--colors-brand-9);
--conditionBuilder-body-bg-color: var(--colors-neutral-line-10);
--conditionBuilder-body-paddingTop: var(--sizes-size-7);
--conditionBuilder-body-paddingTop: var(--sizes-size-3);
--conditionBuilder-body-paddingRight: var(--sizes-size-7);
--conditionBuilder-body-paddingBottom: var(--sizes-size-7);
--conditionBuilder-body-paddingBottom: var(--sizes-size-3);
--conditionBuilder-body-paddingLeft: var(--sizes-base-14);

--table-border-width: var(--borders-width-2);
Expand Down
15 changes: 10 additions & 5 deletions packages/amis-ui/src/components/PopOverContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export interface PopOverOverlay {

export interface PopOverContainerProps {
children: (props: {
disabled?: boolean;
onClick: (e: React.MouseEvent) => void;
isOpened: boolean;
ref: any;
}) => JSX.Element;
disabled?: boolean;
popOverRender: (props: {onClose: () => void}) => JSX.Element;
popOverContainer?: any;
popOverClassName?: string;
Expand Down Expand Up @@ -61,9 +63,10 @@ export class PopOverContainer extends React.Component<

@autobind
handleClick() {
this.setState({
isOpened: true
});
this.props.disabled ||
this.setState({
isOpened: true
});
}

@autobind
Expand Down Expand Up @@ -152,15 +155,17 @@ export class PopOverContainer extends React.Component<
placement,
align,
showConfirm,
onConfirm
onConfirm,
disabled
} = this.props;

return (
<>
{children({
isOpened: this.state.isOpened,
onClick: this.handleClick,
ref: this.targetRef
ref: this.targetRef,
disabled
})}
{mobileUI ? (
<PopUp
Expand Down
3 changes: 2 additions & 1 deletion packages/amis-ui/src/components/condition-builder/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export class ConditionItem extends React.Component<ConditionItemProps> {
return (
<PopOverContainer
mobileUI={mobileUI}
disabled={operators.length < 2}
popOverContainer={popOverContainer || (() => findDOMNode(this))}
popOverRender={({onClose}) => (
<GroupedSelection
Expand All @@ -230,7 +231,7 @@ export class ConditionItem extends React.Component<ConditionItemProps> {
/>
)}
>
{({onClick, isOpened, ref}) => (
{({onClick, isOpened, ref, disabled: popOverDisabled}) => (
<div className={cx('CBGroup-operator')}>
<ResultBox
className={cx(
Expand Down
3 changes: 2 additions & 1 deletion packages/amis-ui/src/components/formula/VariableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function VariableList(props: VariableListProps) {
? props.itemRender
: (option: Option, states: ItemRenderStates): JSX.Element => {
return (
<div>
<div key={states.index}>
<div className={cx(`${classPrefix}-item`, itemClassName)}>
{option.label &&
selfVariableName &&
Expand Down Expand Up @@ -152,6 +152,7 @@ function VariableList(props: VariableListProps) {
{memberOpers.map((item, i) => {
return (
<TooltipWrapper
key={i}
tooltip={item.description}
tooltipTheme="dark"
>
Expand Down

0 comments on commit 45379eb

Please sign in to comment.