Skip to content

Commit

Permalink
fix: tags loading (#1784)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelpashkovsky committed Dec 1, 2022
1 parent 0120da0 commit fb4fee8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
4 changes: 0 additions & 4 deletions webapp/javascript/components/TagsBar.module.css

This file was deleted.

6 changes: 6 additions & 0 deletions webapp/javascript/components/TagsBar.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.loadingWrapper {
display: flex;
height: 80px;
align-items: center;
justify-content: center;
}
28 changes: 20 additions & 8 deletions webapp/javascript/components/TagsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { Query, brandQuery } from '@webapp/models/query';
import Input from '@webapp/ui/Input';
import { appendLabelToQuery } from '@webapp/util/query';
import QueryInput from '@webapp/components/QueryInput/QueryInput';

import LoadingSpinner from '@webapp/ui/LoadingSpinner';
import styles from './TagsBar.module.scss';
interface TagsBarProps {
/** callback for when a label is selected */
onSelectedLabel: (label: string, query: Query) => void;
Expand Down Expand Up @@ -185,17 +186,28 @@ function LabelsSubmenu({
};

const Items = Object.entries(tags).map(([tag, tagValues]) => {
const onChange = (open: boolean) => {
if (open && tagValues.type !== 'loaded') {
onSelectedLabel(tag);
}
};

const values =
tagValues.type === 'loaded' ? (
<MenuGroup takeOverflow>{GetTagValues(tag, tagValues)}</MenuGroup>
) : (
<div className={styles.loadingWrapper}>
<LoadingSpinner />
</div>
);

return (
<SubMenu
key={tag}
overflow="auto"
position="initial"
onChange={(open) => {
// we are opening the menu for the first time
if (open && tagValues.type !== 'loaded') {
onSelectedLabel(tag);
}
}}
onChange={() => onChange(true)}
onMenuChange={({ open }) => onChange(open)}
label={() => (
<span
className="tag-content"
Expand All @@ -207,7 +219,7 @@ function LabelsSubmenu({
)}
>
{GetFilter(tag)}
<MenuGroup takeOverflow>{GetTagValues(tag, tagValues)}</MenuGroup>
{values}
</SubMenu>
);
});
Expand Down

0 comments on commit fb4fee8

Please sign in to comment.