Skip to content

Commit

Permalink
fix:修复tabs激活卡片动作失效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm-lv committed Dec 28, 2023
1 parent 4581c38 commit 5578c58
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/amis/src/renderers/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {FormHorizontal} from 'amis-core';
import {str2AsyncFunction} from 'amis-core';
import {ScopedContext, IScopedContext} from 'amis-core';
import type {TabsMode} from 'amis-ui/lib/components/Tabs';
import isNaN from 'lodash/isNaN';

export interface TabSchema extends Omit<BaseSchema, 'type'> {
/**
Expand Down Expand Up @@ -667,13 +668,13 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
*/
doAction(action: ActionObject, args: any) {
const actionType = action?.actionType as string;
let activeKey = args?.activeKey as number;
// 处理非用户自定义key
if (typeof args?.activeKey !== 'string') {
activeKey--;
}
const tmpKey = Number(args?.activeKey);
let activeKey = isNaN(tmpKey) ? args?.activeKey : tmpKey;

if (actionType === 'changeActiveKey') {
this.handleSelect(activeKey);
this.handleSelect(
typeof activeKey === 'number' ? activeKey - 1 : activeKey
);
}
}

Expand Down

0 comments on commit 5578c58

Please sign in to comment.