Handle paste

Summary: When a user pastes anything, it is treated as an input for a search through the entire row

Reviewed By: lblasa

Differential Revision: D49948975

fbshipit-source-id: 2dd23d4ee0819623549d88eb077c7b2d2fdf604f
This commit is contained in:
Andrey Goncharov
2023-10-05 03:54:29 -07:00
committed by Facebook GitHub Bot
parent c8fc3e6b82
commit 82487be96e

View File

@@ -7,7 +7,7 @@
* @format * @format
*/ */
import {AutoComplete} from 'antd'; import {AutoComplete, Input} from 'antd';
import * as React from 'react'; import * as React from 'react';
export type PowerSearchTermFinderOption = {label: string; value: string}; export type PowerSearchTermFinderOption = {label: string; value: string};
@@ -76,8 +76,22 @@ export const PowerSearchTermFinder = React.forwardRef<
if (event.key === 'Backspace' && !searchTermFinderValue) { if (event.key === 'Backspace' && !searchTermFinderValue) {
onBackspacePressWhileEmpty(); onBackspacePressWhileEmpty();
} }
}} }}>
/> <Input
bordered={false}
onPasteCapture={(event) => {
const text = event.clipboardData.getData('text/plain');
if (text && onConfirmUnknownOption) {
event.stopPropagation();
event.preventDefault();
onConfirmUnknownOption(text);
setSearchTermFinderValue(null);
}
}}
/>
</AutoComplete>
); );
}, },
); );