diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchFloatTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchFloatTerm.tsx new file mode 100644 index 000000000..b66516462 --- /dev/null +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchFloatTerm.tsx @@ -0,0 +1,47 @@ +/** + * 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 PowerSearchFloatTermProps = { + onCancel: () => void; + onChange: (value: number) => void; +}; + +export const PowerSearchFloatTerm: React.FC = ({ + onCancel, + onChange, +}) => { + return ( + { + const newValue = event.target.value; + + if (!newValue) { + onCancel(); + return; + } + + const normalizedValue = parseFloat(newValue); + onChange(normalizedValue); + }} + onKeyDown={(event) => { + if (event.key === 'Enter' || event.key === 'Escape') { + event.currentTarget.blur(); + } + }} + type="number" + step={0.1} + /> + ); +}; diff --git a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx index 3f451a2ba..9d2feecd1 100644 --- a/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx +++ b/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchTerm.tsx @@ -11,6 +11,7 @@ import {CloseOutlined} from '@ant-design/icons'; import {Button, Space} from 'antd'; import * as React from 'react'; import {FieldConfig, OperatorConfig} from './PowerSearchConfig'; +import {PowerSearchFloatTerm} from './PowerSearchFloatTerm'; import {PowerSearchIntegerTerm} from './PowerSearchIntegerTerm'; import {PowerSearchStringTerm} from './PowerSearchStringTerm'; @@ -64,6 +65,20 @@ export const PowerSearchTerm: React.FC = ({ ); break; } + case 'FLOAT': { + searchValueInputComponent = ( + { + onFinalize({ + ...searchTerm, + searchValue: newValue, + }); + }} + /> + ); + break; + } default: { console.error( 'PowerSearchTerm -> unknownoperator.valueType',