mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:48:32 +08:00
commit
f7093678d0
@ -319,7 +319,7 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|||||||
} else {
|
} else {
|
||||||
const tab = this.resolveTabByKey(this.activeKey);
|
const tab = this.resolveTabByKey(this.activeKey);
|
||||||
if (tab && value !== ((tab as any).value ?? tab.title)) {
|
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) {
|
} else if (this.activeKey !== prevState.activeKey) {
|
||||||
const tab = this.resolveTabByKey(this.activeKey);
|
const tab = this.resolveTabByKey(this.activeKey);
|
||||||
if (tab && value !== ((tab as any).value ?? tab.title)) {
|
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
|
@autobind
|
||||||
handleSelect(key: any) {
|
async handleSelect(key: any) {
|
||||||
const {env, onSelect, id} = this.props;
|
const {dispatchEvent, data, env, onSelect, id} = this.props;
|
||||||
|
|
||||||
env.tracker?.({
|
env.tracker?.({
|
||||||
eventType: 'tabChange',
|
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,需要更新到地址栏
|
// 是 hash,需要更新到地址栏
|
||||||
if (typeof key === 'string' && env) {
|
if (typeof key === 'string' && env) {
|
||||||
env.updateLocation(`#${key}`);
|
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