From 82487be96ec1d658519dc713db0e34d5a6a88b54 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Thu, 5 Oct 2023 03:54:29 -0700 Subject: [PATCH] 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 --- .../ui/PowerSearch/PowerSearchTermFinder.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTermFinder.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTermFinder.tsx index 5cdef1961..c8cc37f7c 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTermFinder.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTermFinder.tsx @@ -7,7 +7,7 @@ * @format */ -import {AutoComplete} from 'antd'; +import {AutoComplete, Input} from 'antd'; import * as React from 'react'; export type PowerSearchTermFinderOption = {label: string; value: string}; @@ -76,8 +76,22 @@ export const PowerSearchTermFinder = React.forwardRef< if (event.key === 'Backspace' && !searchTermFinderValue) { onBackspacePressWhileEmpty(); } - }} - /> + }}> + { + const text = event.clipboardData.getData('text/plain'); + + if (text && onConfirmUnknownOption) { + event.stopPropagation(); + event.preventDefault(); + + onConfirmUnknownOption(text); + setSearchTermFinderValue(null); + } + }} + /> + ); }, );