Skip to content

Commit b922d64

Browse files
authored
RI-7401: fix key name input layout on focus (#5016)
1 parent 37ec3ac commit b922d64

File tree

2 files changed

+64
-80
lines changed

2 files changed

+64
-80
lines changed

redisinsight/ui/src/pages/browser/modules/key-details-header/components/key-details-header-name/KeyDetailsHeaderName.tsx

Lines changed: 62 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@ import {
1919
sendEventTelemetry,
2020
TelemetryEvent,
2121
} from 'uiSrc/telemetry'
22-
import {
23-
formatLongName,
24-
isEqualBuffers,
25-
replaceSpaces,
26-
stringToBuffer,
27-
} from 'uiSrc/utils'
22+
import { formatLongName, isEqualBuffers, stringToBuffer } from 'uiSrc/utils'
2823

2924
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
3025
import { IconButton } from 'uiSrc/components/base/forms/buttons'
3126
import { CopyIcon } from 'uiSrc/components/base/icons'
32-
import { Text } from 'uiSrc/components/base/text'
3327
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
3428
import { RiTooltip } from 'uiSrc/components'
3529
import { TextInput } from 'uiSrc/components/base/inputs'
@@ -40,6 +34,11 @@ const StyledInputWrapper = styled(Row)`
4034
min-width: 150px;
4135
`
4236

37+
const StyledFlexWrapper = styled(FlexItem)`
38+
max-width: 450px;
39+
gap: ${({ theme }) => theme.core.space.space050};
40+
`
41+
4342
export interface Props {
4443
onEditKey: (
4544
key: RedisResponseBuffer,
@@ -146,84 +145,69 @@ const KeyDetailsHeaderName = ({ onEditKey }: Props) => {
146145
}
147146

148147
return (
149-
<FlexItem
150-
grow={5}
148+
<StyledFlexWrapper
149+
grow={10}
151150
direction="row"
152151
onMouseEnter={onMouseEnterKey}
153152
onMouseLeave={onMouseLeaveKey}
154153
onClick={onClickKey}
155-
$gap="xs"
156154
data-testid="edit-key-btn"
157155
>
158-
{keyIsEditing || keyIsHovering ? (
159-
<RiTooltip
160-
title="Key Name"
161-
position="left"
162-
content={tooltipContent}
163-
anchorClassName={styles.toolTipAnchorKey}
164-
>
165-
<InlineItemEditor
166-
onApply={() => applyEditKey()}
167-
isDisabled={!keyIsEditable}
168-
disabledTooltipText={TEXT_UNPRINTABLE_CHARACTERS}
169-
onDecline={(event) => cancelEditKey(event)}
170-
viewChildrenMode={!keyIsEditing}
171-
isLoading={loading}
172-
declineOnUnmount={false}
173-
>
174-
<StyledInputWrapper align="center">
175-
<TextInput
176-
name="key"
177-
id="key"
178-
ref={keyNameRef}
179-
className={cx(styles.keyInput, {
180-
[styles.keyInputEditing]: keyIsEditing,
181-
'input-warning': !keyIsEditable,
182-
})}
183-
placeholder={AddCommonFieldsFormConfig?.keyName?.placeholder}
184-
value={key!}
185-
loading={loading}
186-
onChange={onChangeKey}
187-
readOnly={!keyIsEditing}
188-
autoComplete="off"
189-
data-testid="edit-key-input"
190-
// todo: do not hardcode. align with other components in a single place
191-
style={{ paddingLeft: 9, lineHeight: '31px' }}
192-
/>
193-
{!keyIsEditing && <RiIcon size="M" type="EditIcon" />}
194-
</StyledInputWrapper>
195-
</InlineItemEditor>
196-
</RiTooltip>
197-
) : (
198-
<Text
199-
className={cx(styles.key, {
200-
[styles.hidden]: keyIsEditing || keyIsHovering,
201-
})}
202-
data-testid="key-name-text"
203-
>
204-
<b className="truncateText">
205-
{replaceSpaces(keyProp?.substring(0, 200))}
206-
</b>
207-
</Text>
208-
)}
209-
{keyIsHovering && (
210-
<RiTooltip
211-
position="right"
212-
content="Copy"
213-
anchorClassName={styles.copyKey}
156+
<RiTooltip
157+
title="Key Name"
158+
position="left"
159+
content={tooltipContent}
160+
anchorClassName={styles.toolTipAnchorKey}
161+
>
162+
<InlineItemEditor
163+
onApply={() => applyEditKey()}
164+
isDisabled={!keyIsEditable}
165+
disabledTooltipText={TEXT_UNPRINTABLE_CHARACTERS}
166+
onDecline={(event) => cancelEditKey(event)}
167+
viewChildrenMode={!keyIsEditing}
168+
isLoading={loading}
169+
declineOnUnmount={false}
214170
>
215-
<IconButton
216-
icon={CopyIcon}
217-
id={COPY_KEY_NAME_ICON}
218-
aria-label="Copy key name"
219-
onClick={(event: any) =>
220-
handleCopy(event, key!, keyIsEditing, keyNameRef)
221-
}
222-
data-testid="copy-key-name-btn"
223-
/>
224-
</RiTooltip>
225-
)}
226-
</FlexItem>
171+
<StyledInputWrapper align="center">
172+
<TextInput
173+
name="key"
174+
id="key"
175+
ref={keyNameRef}
176+
className={cx(styles.keyInput, {
177+
[styles.keyInputEditing]: keyIsEditing,
178+
'input-warning': !keyIsEditable,
179+
})}
180+
placeholder={AddCommonFieldsFormConfig?.keyName?.placeholder}
181+
value={key!}
182+
loading={loading}
183+
onChange={onChangeKey}
184+
readOnly={!keyIsEditing}
185+
autoComplete="off"
186+
data-testid="edit-key-input"
187+
// todo: do not hardcode. align with other components in a single place
188+
style={{ paddingLeft: 9, lineHeight: '31px' }}
189+
/>
190+
{!keyIsEditing && <RiIcon size="M" type="EditIcon" />}
191+
</StyledInputWrapper>
192+
</InlineItemEditor>
193+
</RiTooltip>
194+
<RiTooltip
195+
position="right"
196+
content="Copy"
197+
anchorClassName={styles.copyKey}
198+
>
199+
<IconButton
200+
icon={CopyIcon}
201+
id={COPY_KEY_NAME_ICON}
202+
aria-label="Copy key name"
203+
onClick={(event: any) =>
204+
handleCopy(event, key!, keyIsEditing, keyNameRef)
205+
}
206+
data-testid="copy-key-name-btn"
207+
className={!keyIsHovering ? styles.hidden : ''}
208+
/>
209+
</RiTooltip>
210+
</StyledFlexWrapper>
227211
)
228212
}
229213

redisinsight/ui/src/pages/browser/modules/key-details-header/components/key-details-header-name/styles.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
font-size: 14px !important;
1919
font-weight: 500 !important;
2020
flex: 1;
21-
max-width: 400px;
21+
min-width: 150px;
2222
white-space: nowrap;
2323
overflow: hidden;
2424
text-overflow: ellipsis;
@@ -62,5 +62,5 @@
6262
}
6363

6464
.hidden {
65-
display: none;
65+
visibility: hidden;
6666
}

0 commit comments

Comments
 (0)