diff --git a/components/_util/transButton.tsx b/components/_util/transButton.tsx index 08c3d780af..5fc0ec7a02 100644 --- a/components/_util/transButton.tsx +++ b/components/_util/transButton.tsx @@ -6,7 +6,7 @@ import * as React from 'react'; import KeyCode from 'rc-util/lib/KeyCode'; interface TransButtonProps extends React.HTMLAttributes { - onClick?: () => void; + onClick?: (e?: React.MouseEvent) => void; } const inlineStyle: React.CSSProperties = { diff --git a/components/page-header/__tests__/index.test.js b/components/page-header/__tests__/index.test.js index 7c67957a19..83fc6954c0 100644 --- a/components/page-header/__tests__/index.test.js +++ b/components/page-header/__tests__/index.test.js @@ -21,7 +21,7 @@ describe('PageHeader', () => { const wrapper = mount(); 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(); 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(); - wrapper.find('.ant-page-header-back-icon').simulate('click'); + wrapper.find('div.ant-page-header-back-icon-button').simulate('click'); expect(callback).toHaveBeenCalled(); }); diff --git a/components/page-header/index.tsx b/components/page-header/index.tsx index 52fbb83d4f..fb626de5e0 100644 --- a/components/page-header/index.tsx +++ b/components/page-header/index.tsx @@ -19,7 +19,7 @@ export interface PageHeaderProps { tags?: React.ReactElement | React.ReactElement[]; footer?: React.ReactNode; extra?: React.ReactNode; - onBack?: (e: React.MouseEvent) => void; + onBack?: (e: React.MouseEvent) => void; className?: string; } @@ -34,15 +34,16 @@ const renderBack = ( return ( {({ back }: { back: string }) => ( -
{ - if (onBack) { - onBack(e); - } - }} - > - +
+ ) => { + if (onBack) { + onBack(e); + } + }} + className={`${prefixCls}-back-icon-button`} + aria-label={back} + > {backIcon}