Skip to content

Commit e3df2cb

Browse files
authored
RI-7779: remove duplicate tooltip in tag input field (#5313)
Remove RiTooltip wrapper and rely on TextInput built-in error tooltip to fix misaligned tooltip text colors. Move types to dedicated file. Closes: #RI-7779
1 parent 7001541 commit e3df2cb

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

redisinsight/ui/src/pages/home/components/database-manage-tags-modal/TagInputField.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
import React, { useState } from 'react'
22

3-
import { RiTooltip } from 'uiSrc/components'
43
import { TextInput } from 'uiSrc/components/base/inputs'
54
import { TagSuggestions } from './TagSuggestions'
6-
7-
type TagInputFieldProps = {
8-
value: string
9-
disabled?: boolean
10-
currentTagKeys: Set<string>
11-
suggestedTagKey?: string
12-
rightContent?: React.ReactNode
13-
errorMessage?: string
14-
placeholder?: string
15-
onChange: (value: string) => void
16-
}
5+
import { TagInputFieldProps } from './TagInputField.types'
176

187
export const TagInputField = ({
198
value,
@@ -30,7 +19,7 @@ export const TagInputField = ({
3019

3120
return (
3221
<div>
33-
<RiTooltip content={errorMessage} position="top">
22+
<span>
3423
<TextInput
3524
value={value}
3625
disabled={disabled}
@@ -58,7 +47,7 @@ export const TagInputField = ({
5847
}}
5948
/>
6049
)}
61-
</RiTooltip>
50+
</span>
6251
{rightContent}
6352
</div>
6453
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type TagInputFieldProps = {
2+
value: string
3+
disabled?: boolean
4+
currentTagKeys: Set<string>
5+
suggestedTagKey?: string
6+
rightContent?: React.ReactNode
7+
errorMessage?: string
8+
placeholder?: string
9+
onChange: (value: string) => void
10+
}
11+

redisinsight/ui/src/pages/home/components/database-manage-tags-modal/TagSuggestions.tsx

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,35 @@ export const TagSuggestions = ({
2626
}: TagSuggestionsProps) => {
2727
const { data: allTags } = useSelector(tagsSelector)
2828
const tagsSuggestions: SelectOption[] = useMemo(() => {
29-
const options = uniqBy(presetTagSuggestions.concat(allTags), (tag) =>
30-
targetKey ? tag.value : tag.key,
31-
)
32-
.filter(({ key, value }) => {
33-
if (targetKey !== undefined) {
34-
return (
35-
key === targetKey && value !== '' && value.includes(searchTerm)
36-
)
37-
}
29+
const options = uniqBy(presetTagSuggestions.concat(allTags), (tag) =>
30+
targetKey ? tag.value : tag.key,
31+
)
32+
.filter(({ key, value }) => {
33+
if (targetKey !== undefined) {
34+
return key === targetKey && value !== '' && value.includes(searchTerm)
35+
}
3836

39-
return (
40-
key.includes(searchTerm) &&
41-
(!currentTagKeys.has(key) || key === searchTerm)
42-
)
43-
})
44-
.map(({ key, value }) => ({
45-
label: targetKey ? value : key,
46-
value: targetKey ? value : key,
47-
}))
37+
return (
38+
key.includes(searchTerm) &&
39+
(!currentTagKeys.has(key) || key === searchTerm)
40+
)
41+
})
42+
.map(({ key, value }) => ({
43+
label: targetKey ? value : key,
44+
value: targetKey ? value : key,
45+
}))
4846

49-
const isNewTag = options.length === 0 && searchTerm
47+
const isNewTag = options.length === 0 && searchTerm
5048

51-
if (isNewTag) {
52-
options.push({
53-
label: `${searchTerm} (new ${targetKey ? 'value' : 'tag'})`,
54-
value: searchTerm,
55-
})
56-
}
49+
if (isNewTag) {
50+
options.push({
51+
label: `${searchTerm} (new ${targetKey ? 'value' : 'tag'})`,
52+
value: searchTerm,
53+
})
54+
}
5755

58-
return options
59-
}, [allTags, targetKey, searchTerm, currentTagKeys])
56+
return options
57+
}, [allTags, targetKey, searchTerm, currentTagKeys])
6058

6159
if (tagsSuggestions.length === 0) {
6260
return null

0 commit comments

Comments
 (0)