diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchStringTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchStringTerm.tsx new file mode 100644 index 000000000..4c3ef860f --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchStringTerm.tsx @@ -0,0 +1,44 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {Input} from 'antd'; +import React from 'react'; + +type PowerSearchStringTermProps = { + onCancel: () => void; + onChange: (value: string) => void; +}; + +export const PowerSearchStringTerm: React.FC = ({ + onCancel, + onChange, +}) => { + return ( + { + const newValue = event.target.value; + + if (!newValue) { + onCancel(); + return; + } + + onChange(newValue); + }} + onKeyDown={(event) => { + if (event.key === 'Enter' || event.key === 'Escape') { + event.currentTarget.blur(); + } + }} + /> + ); +}; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx index 7ffb2b774..932d5dff3 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx @@ -8,9 +8,10 @@ */ import {CloseOutlined} from '@ant-design/icons'; -import {Button, Input, Space} from 'antd'; +import {Button, Space} from 'antd'; import * as React from 'react'; import {FieldConfig, OperatorConfig} from './PowerSearchConfig'; +import {PowerSearchStringTerm} from './PowerSearchStringTerm'; export type IncompleteSearchExpressionTerm = { field: FieldConfig; @@ -39,29 +40,14 @@ export const PowerSearchTerm: React.FC = ({ {searchValueRenderer === 'button' ? ( ) : ( - // TODO: Fix width - { - const newValue = event.target.value; - - if (!newValue) { - onCancel(); - return; - } - + { onFinalize({ ...searchTerm, searchValue: newValue, }); }} - onKeyDown={(event) => { - if (event.key === 'Enter' || event.key === 'Escape') { - event.currentTarget.blur(); - } - }} /> )}