Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Reorder props & fix small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt committed Nov 6, 2023
1 parent a60d033 commit 0a39097
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/components/TablePopover/TableFilterPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { TreeDataEntry, TreeSelect } from "../TreeSelect";
const { blue, gray } = palette;

interface TableFilterPopoverProps {
value: string[];
options: TreeDataEntry[];
onConfirm: (filters: string[]) => void;
"data-cy"?: string;
onConfirm: (filters: string[]) => void;
options: TreeDataEntry[];
value: string[];
}

export const TableFilterPopover: React.FC<TableFilterPopoverProps> = ({
Expand All @@ -38,7 +38,7 @@ export const TableFilterPopover: React.FC<TableFilterPopoverProps> = ({
};

return (
<Wrapper>
<FilterWrapper>
<IconButton
onClick={() => setActive(!active)}
active={active}
Expand All @@ -58,10 +58,10 @@ export const TableFilterPopover: React.FC<TableFilterPopoverProps> = ({
/>
</PopoverContainer>
</Popover>
</Wrapper>
</FilterWrapper>
);
};

const Wrapper = styled.div`
const FilterWrapper = styled.div`
margin-left: ${size.xxs};
`;
19 changes: 12 additions & 7 deletions src/components/TablePopover/TableSearchPopover.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useRef } from "react";
import { useState, useEffect, useRef } from "react";
import styled from "@emotion/styled";
import Icon from "@leafygreen-ui/icon";
import IconButton from "@leafygreen-ui/icon-button";
Expand All @@ -12,10 +12,10 @@ import { useOnClickOutside } from "hooks";
const { blue, gray } = palette;

interface TableSearchPopoverProps {
value: string;
onConfirm: (search: string) => void;
"data-cy"?: string;
onConfirm: (search: string) => void;
placeholder?: string;
value: string;
}

export const TableSearchPopover: React.FC<TableSearchPopoverProps> = ({
Expand All @@ -26,21 +26,26 @@ export const TableSearchPopover: React.FC<TableSearchPopoverProps> = ({
}) => {
const [input, setInput] = useState(value);
const [active, setActive] = useState(false);
const iconColor = input === "" ? gray.dark2 : blue.base;
const iconColor = value === "" ? gray.dark2 : blue.base;

const buttonRef = useRef(null);
const popoverRef = useRef(null);

// Handle onClickOutside
useOnClickOutside([buttonRef, popoverRef], () => setActive(false));

// If the value from the URL has changed, update the input.
useEffect(() => {
setInput(value);
}, [value]);

const onEnter = () => {
onConfirm(input);
setActive(false);
};

return (
<Wrapper>
<SearchWrapper>
<IconButton
onClick={() => setActive(!active)}
active={active}
Expand All @@ -65,10 +70,10 @@ export const TableSearchPopover: React.FC<TableSearchPopoverProps> = ({
/>
</PopoverContainer>
</Popover>
</Wrapper>
</SearchWrapper>
);
};

const Wrapper = styled.div`
const SearchWrapper = styled.div`
margin-left: ${size.xxs};
`;
10 changes: 6 additions & 4 deletions src/pages/version/taskDuration/TaskDurationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ export const TaskDurationTable: React.FC<Props> = ({ loading, tasks }) => {

const sorting = useMemo(
() => [
{
id: PatchTasksQueryParams.Duration,
desc: duration !== "ASC",
},
...(duration && [
{
id: PatchTasksQueryParams.Duration,
desc: duration === "DESC",
},
]),
],
[duration]
);
Expand Down

0 comments on commit 0a39097

Please sign in to comment.