Skip to content

Commit bbcf01a

Browse files
committed
replace settings item, used in workbench and advanced settings
1 parent 544b75c commit bbcf01a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

redisinsight/ui/src/components/settings-item/SettingItem.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import React, { ChangeEvent, useEffect, useState } from 'react'
1+
import React, { ReactNode, useEffect, useState } from 'react'
22
import cx from 'classnames'
3-
import { EuiFieldNumber, EuiIcon, EuiText, EuiTitle } from '@elastic/eui'
3+
import { EuiIcon, EuiText, EuiTitle } from '@elastic/eui'
44

55
import InlineItemEditor from 'uiSrc/components/inline-item-editor/InlineItemEditor'
66

77
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
88
import { Spacer } from 'uiSrc/components/base/layout/spacer'
9+
import { NumericInput } from 'uiSrc/components/base/inputs'
910
import styles from './styles.module.scss'
1011

1112
export interface Props {
@@ -53,12 +54,6 @@ const SettingItem = (props: Props) => {
5354
setHovering(false)
5455
}
5556

56-
const onChange = ({
57-
currentTarget: { value },
58-
}: ChangeEvent<HTMLInputElement>) => {
59-
isEditing && setValue(validation(value))
60-
}
61-
6257
const appendEditing = () =>
6358
!isEditing ? <EuiIcon type="pencil" color="subdued" /> : ''
6459

@@ -94,19 +89,20 @@ const SettingItem = (props: Props) => {
9489
onDecline={handleDeclineChanges}
9590
declineOnUnmount={false}
9691
>
97-
<EuiFieldNumber
98-
onChange={onChange}
99-
value={value}
92+
<NumericInput
93+
autoValidate
94+
onChange={(value) =>
95+
isEditing &&
96+
setValue(validation(value ? value.toString() : ''))
97+
}
98+
value={Number(value)}
10099
placeholder={placeholder}
101100
aria-label={testid?.replaceAll?.('-', ' ')}
101+
append={appendEditing()}
102102
className={cx(styles.input, {
103103
[styles.inputEditing]: isEditing,
104+
[styles.inputHover]: isHovering,
104105
})}
105-
append={appendEditing()}
106-
fullWidth={false}
107-
compressed
108-
autoComplete="off"
109-
type="text"
110106
readOnly={!isEditing}
111107
data-testid={`${testid}-input`}
112108
/>

redisinsight/ui/src/components/settings-item/styles.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
height: 32px !important;
88
}
99

10+
.inputHover {
11+
line-height: 3.2rem !important;
12+
}
13+
1014
.container {
1115
height: 40px;
1216

0 commit comments

Comments
 (0)