mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
change onclick dom
This commit is contained in:
parent
1ece80f6bc
commit
6055905ae4
@ -6,7 +6,7 @@ import * as React from 'react';
|
||||
import KeyCode from 'rc-util/lib/KeyCode';
|
||||
|
||||
interface TransButtonProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
onClick?: () => void;
|
||||
onClick?: (e?: React.MouseEvent<HTMLDivElement>) => void;
|
||||
}
|
||||
|
||||
const inlineStyle: React.CSSProperties = {
|
||||
|
@ -21,7 +21,7 @@ describe('PageHeader', () => {
|
||||
const wrapper = mount(<PageHeader title="Page Title" breadcrumb={{ routes }} />);
|
||||
expect(wrapper.find('.ant-page-header-back-icon')).toHaveLength(0);
|
||||
});
|
||||
it('pageHeader should no contain back it back', () => {
|
||||
it('pageHeader should no contain back', () => {
|
||||
const wrapper = mount(<PageHeader title="Page Title" backIcon={false} />);
|
||||
expect(wrapper.find('.ant-page-header-back-icon')).toHaveLength(0);
|
||||
});
|
||||
@ -35,7 +35,7 @@ describe('PageHeader', () => {
|
||||
it('pageHeader onBack transfer', () => {
|
||||
const callback = jest.fn(() => true);
|
||||
const wrapper = mount(<PageHeader title="Page Title" onBack={callback} />);
|
||||
wrapper.find('.ant-page-header-back-icon').simulate('click');
|
||||
wrapper.find('div.ant-page-header-back-icon-button').simulate('click');
|
||||
expect(callback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,7 @@ export interface PageHeaderProps {
|
||||
tags?: React.ReactElement<Tag> | React.ReactElement<Tag>[];
|
||||
footer?: React.ReactNode;
|
||||
extra?: React.ReactNode;
|
||||
onBack?: (e: React.MouseEvent<HTMLElement>) => void;
|
||||
onBack?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
@ -34,15 +34,16 @@ const renderBack = (
|
||||
return (
|
||||
<LocaleReceiver componentName="PageHeader">
|
||||
{({ back }: { back: string }) => (
|
||||
<div
|
||||
className={`${prefixCls}-back-icon`}
|
||||
onClick={e => {
|
||||
if (onBack) {
|
||||
onBack(e);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<TransButton className={`${prefixCls}-back-icon-button`} aria-label={back}>
|
||||
<div className={`${prefixCls}-back-icon`}>
|
||||
<TransButton
|
||||
onClick={(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (onBack) {
|
||||
onBack(e);
|
||||
}
|
||||
}}
|
||||
className={`${prefixCls}-back-icon-button`}
|
||||
aria-label={back}
|
||||
>
|
||||
{backIcon}
|
||||
</TransButton>
|
||||
<Divider type="vertical" />
|
||||
|
Loading…
Reference in New Issue
Block a user