fix: press enter to reload when the Pagination is focused (#1720)

This commit is contained in:
saxon-y 2023-04-19 12:22:01 +08:00 committed by GitHub
parent a5b4684a48
commit 3e2b0a3e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { observer } from '@formily/react'; import { observer } from '@formily/react';
import { Pagination as AntdPagination } from 'antd'; import { Pagination as AntdPagination } from 'antd';
import React from 'react'; import React, { KeyboardEventHandler } from 'react';
import { useProps } from '../../hooks/useProps'; import { useProps } from '../../hooks/useProps';
export const Pagination = observer((props: any) => { export const Pagination = observer((props: any) => {
@ -8,5 +8,15 @@ export const Pagination = observer((props: any) => {
if (hidden) { if (hidden) {
return null; return null;
} }
return <AntdPagination {...others} />; const onKeypress: KeyboardEventHandler<HTMLDivElement> = (e) => {
if (e.key === 'Enter') {
e.preventDefault();
}
};
return (
<div onKeyPress={onKeypress}>
<AntdPagination {...others} />;
</div>
);
}); });