Skip to content

Commit d76092f

Browse files
authored
fix(schema-hints): Add interactivity to UI (#87227)
Shruthi made some good quality of life improvement suggestions in [this PR](#87027 (review)). I've addressed them both in this pr: - showing `cursor: pointer` on the entire row since it is clickable - highlighting rows on hover + on click - moving selected hints on the top of the list Here's what it looks like: https://github.com/user-attachments/assets/33fed802-df3d-409a-b467-e3e938dda455 (idk why the pointer cursor doesn't show when you're screen recording) Contributes to #86484
1 parent 9599396 commit d76092f

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

static/app/views/explore/components/schemaHintsDrawer.tsx

+32-9
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,28 @@ function SchemaHintsDrawer({hints}: SchemaHintsDrawerProps) {
2929
return filterQuery.getFilterKeys();
3030
}, [exploreQuery]);
3131

32-
const sortedHints = useMemo(() => {
33-
return hints.toSorted((a, b) => {
34-
// may need to fix this if we don't want to ignore the prefix
35-
const aWithoutPrefix = prettifyTagKey(a.key).replace(/^_/, '');
36-
const bWithoutPrefix = prettifyTagKey(b.key).replace(/^_/, '');
37-
return aWithoutPrefix.localeCompare(bWithoutPrefix);
32+
const sortedSelectedHints = useMemo(() => {
33+
const sortedKeys = selectedFilterKeys.toSorted((a, b) => {
34+
return prettifyTagKey(a).localeCompare(prettifyTagKey(b));
3835
});
39-
}, [hints]);
36+
return sortedKeys
37+
.map(key => hints.find(hint => hint.key === key))
38+
.filter(tag => !!tag);
39+
}, [hints, selectedFilterKeys]);
40+
41+
const sortedHints = useMemo(() => {
42+
return [
43+
...new Set([
44+
...sortedSelectedHints,
45+
...hints.toSorted((a, b) => {
46+
// may need to fix this if we don't want to ignore the prefix
47+
const aWithoutPrefix = prettifyTagKey(a.key).replace(/^_/, '');
48+
const bWithoutPrefix = prettifyTagKey(b.key).replace(/^_/, '');
49+
return aWithoutPrefix.localeCompare(bWithoutPrefix);
50+
}),
51+
]),
52+
];
53+
}, [hints, sortedSelectedHints]);
4054

4155
const handleCheckboxChange = useCallback(
4256
(hint: Tag) => {
@@ -114,7 +128,8 @@ const CheckboxLabelContainer = styled('div')`
114128
justify-content: space-between;
115129
width: 100%;
116130
gap: ${space(1)};
117-
padding-right: ${space(0.5)};
131+
cursor: pointer;
132+
padding-right: ${space(0.25)};
118133
`;
119134

120135
const CheckboxLabel = styled('span')`
@@ -129,13 +144,21 @@ const StyledMultipleCheckbox = styled(MultipleCheckbox)`
129144

130145
const StyledMultipleCheckboxItem = styled(MultipleCheckbox.Item)`
131146
width: 100%;
132-
padding: ${space(1)} 0;
147+
padding: ${space(1)} ${space(0.5)};
133148
border-top: 1px solid ${p => p.theme.border};
134149
135150
@media (min-width: ${p => p.theme.breakpoints.small}) {
136151
width: 100%;
137152
}
138153
154+
&:hover {
155+
background-color: ${p => p.theme.backgroundSecondary};
156+
}
157+
158+
&:active {
159+
background-color: ${p => p.theme.gray100};
160+
}
161+
139162
&:last-child {
140163
border-bottom: 1px solid ${p => p.theme.border};
141164
}

0 commit comments

Comments
 (0)