Skip to content

Commit

Permalink
fix: the display only filter doesn't render a search box
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed May 27, 2021
1 parent 4b16eee commit 80cab71
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/components/FilterableTable/Filters/DisplayOnlyFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import TableFilter from './TableFilter';

export default class DisplayOnlyFilter extends TableFilter {
constructor(title) {
super(title, undefined, {sortable: false, filterable: false});
}

Component = () => <td />;
}
2 changes: 1 addition & 1 deletion app/components/FilterableTable/Filters/TableFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default abstract class TableFilter<T = string | number | boolean> {
sortColumnName: string;
isSearchEnabled: boolean;
isSortEnabled: boolean;
removeSearchHeader: boolean;

/**
* The array of all relay arguments managed by this filter.
Expand All @@ -56,6 +55,7 @@ export default abstract class TableFilter<T = string | number | boolean> {
name={this.argName}
value={(filterArgs[this.argName] ?? '') as string | number}
aria-label={`Filter by ${this.title}`}
disabled={!this.isSearchEnabled}
onChange={(evt) =>
onChange(this.castValue(evt.target.value) as any, this.argName)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import {DisplayOnlyFilter} from 'components/FilterableTable/Filters';
import {mount} from 'enzyme';

describe('the display only filter option', () => {
const filterUnderTest = new DisplayOnlyFilter('display header');

it('renders an empty td component', () => {
const rendered = mount(<filterUnderTest.Component />);
expect(rendered).toMatchSnapshot();
});

it('should not be sortable or searchable', () => {
expect(filterUnderTest.isSearchEnabled).toBeFalse();
expect(filterUnderTest.isSortEnabled).toBeFalse();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`the display only filter option renders an empty td component 1`] = `<td />`;

0 comments on commit 80cab71

Please sign in to comment.