mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:29:24 +08:00
commit
f7093678d0
@ -319,7 +319,7 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
||||
} else {
|
||||
const tab = this.resolveTabByKey(this.activeKey);
|
||||
if (tab && value !== ((tab as any).value ?? tab.title)) {
|
||||
this.handleChange((tab as any).value ?? tab.title, name);
|
||||
onChange((tab as any).value ?? tab.title, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -438,7 +438,7 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
||||
} else if (this.activeKey !== prevState.activeKey) {
|
||||
const tab = this.resolveTabByKey(this.activeKey);
|
||||
if (tab && value !== ((tab as any).value ?? tab.title)) {
|
||||
this.handleChange((tab as any).value ?? tab.title, name);
|
||||
onChange((tab as any).value ?? tab.title, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -566,8 +566,8 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleSelect(key: any) {
|
||||
const {env, onSelect, id} = this.props;
|
||||
async handleSelect(key: any) {
|
||||
const {dispatchEvent, data, env, onSelect, id} = this.props;
|
||||
|
||||
env.tracker?.({
|
||||
eventType: 'tabChange',
|
||||
@ -577,6 +577,16 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
||||
}
|
||||
});
|
||||
|
||||
const rendererEvent = await dispatchEvent(
|
||||
'change',
|
||||
createObject(data, {
|
||||
value: key
|
||||
})
|
||||
);
|
||||
if (rendererEvent?.prevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 是 hash,需要更新到地址栏
|
||||
if (typeof key === 'string' && env) {
|
||||
env.updateLocation(`#${key}`);
|
||||
@ -597,22 +607,6 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
async handleChange(key: any, name: any) {
|
||||
const {dispatchEvent, data, onChange} = this.props;
|
||||
const rendererEvent = await dispatchEvent(
|
||||
'change',
|
||||
createObject(data, {
|
||||
value: key
|
||||
})
|
||||
);
|
||||
if (rendererEvent?.prevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
onChange && onChange(key, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动作处理
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user