Skip to content

Commit

Permalink
Fix filter in Catalog view (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Nov 20, 2019
1 parent eb7222b commit 3cc0bac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions dashboard/src/components/Catalog/Catalog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ it("updates the filter from props", () => {
expect(wrapper.state("filter")).toBe("foo");
});

it("keeps the filter from the state", () => {
const wrapper = shallow(<Catalog {...defaultProps} />);
expect(wrapper.state("filter")).toBe("");
wrapper.setState({ filter: "foo" });
expect(wrapper.state("filter")).toBe("foo");
});

describe("renderization", () => {
context("when no charts", () => {
it("should render an error", () => {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/Catalog/Catalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Catalog extends React.Component<ICatalogProps, ICatalogState> {
}

public componentDidUpdate(prevProps: ICatalogProps) {
if (this.props.filter !== this.state.filter) {
if (this.props.filter !== prevProps.filter) {
this.setState({ filter: this.props.filter });
}
if (this.props.repo !== prevProps.repo) {
Expand Down

0 comments on commit 3cc0bac

Please sign in to comment.