Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiDelayRender #1876

Merged
merged 24 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1098550
filter toggle buttons are labeled now as proper aria toggle buttons =…
PhilippBaranovskiy Apr 23, 2019
4999ac0
Introduces delay render component (similar to delay hide), which allo…
PhilippBaranovskiy Apr 23, 2019
b1b0b88
PR snapshots updates
PhilippBaranovskiy Apr 23, 2019
353895d
Merge branch 'master' into 749
PhilippBaranovskiy Apr 23, 2019
6bf2976
Adjusting delay timout to 500ms
PhilippBaranovskiy Apr 23, 2019
d2810f1
PR snapshots updates
PhilippBaranovskiy Apr 23, 2019
2dd03cd
put aria-label atts back as they are no longer needed
PhilippBaranovskiy Apr 23, 2019
1b7a592
review edits
PhilippBaranovskiy May 6, 2019
3c27943
Merge branch 'master' into 749
PhilippBaranovskiy May 6, 2019
6be035c
following up feedback comments
PhilippBaranovskiy May 7, 2019
b311622
following up feedback comments
PhilippBaranovskiy May 7, 2019
f1e0c93
...
PhilippBaranovskiy May 7, 2019
7fc3dec
Merge branch 'master' into 749
PhilippBaranovskiy May 13, 2019
35f536d
update snapshot
PhilippBaranovskiy May 13, 2019
d4ff07b
set initial render as delayed
PhilippBaranovskiy May 13, 2019
d32b799
update documentation
PhilippBaranovskiy May 13, 2019
c17604b
update change log
PhilippBaranovskiy May 13, 2019
4c00a6c
string parameters conversion, snapshot updating
PhilippBaranovskiy May 14, 2019
7b38907
update snapshots
PhilippBaranovskiy May 22, 2019
a229f79
Merge branch 'master' into 749
PhilippBaranovskiy May 22, 2019
06e7fca
Merge branch 'master' into 749
PhilippBaranovskiy May 23, 2019
2cd2630
Merge branch 'master' into 749
PhilippBaranovskiy May 30, 2019
426ef3b
Merge branch 'master' into 749
PhilippBaranovskiy May 31, 2019
ba897c7
Merge branch 'master' into 749
PhilippBaranovskiy Jun 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
460 changes: 276 additions & 184 deletions src/components/basic_table/__snapshots__/basic_table.test.js.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,9 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
className="euiScreenReaderOnly"
role="status"
>
<EuiI18n
default="Below is a table of {itemCount} items."
token="euiBasicTable.tableDescription"
values={
Object {
"itemCount": 2,
}
}
>
Below is a table of 2 items.
</EuiI18n>
<EuiDelayRender
delay={500}
/>
</caption>
</EuiScreenReaderOnly>
<EuiTableHeader>
Expand Down
17 changes: 11 additions & 6 deletions src/components/basic_table/basic_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { EuiTableSortMobile } from '../table/mobile/table_sort_mobile';
import { withRequiredProp } from '../../utils/prop_types/with_required_prop';
import { EuiScreenReaderOnly, EuiKeyboardAccessible } from '../accessibility';
import { EuiI18n } from '../i18n';
import { EuiDelayRender } from '../delay_render';
import makeId from '../form/form_row/make_id';

const dataTypesProfiles = {
Expand Down Expand Up @@ -240,8 +241,10 @@ export class EuiBasicTable extends Component {
constructor(props) {
super(props);
this.state = {
selection: []
selection: [],
isDelaying: true,
};
this.delayID = null;
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
}

static buildCriteria(props) {
Expand Down Expand Up @@ -430,11 +433,13 @@ export class EuiBasicTable extends Component {
return (
<EuiScreenReaderOnly>
<caption role="status" aria-relevant="text" aria-live="polite">
<EuiI18n
token="euiBasicTable.tableDescription"
default="Below is a table of {itemCount} items."
values={{ itemCount: items.length }}
/>
<EuiDelayRender>
<EuiI18n
token="euiBasicTable.tableDescription"
default="Below is a table of {itemCount} items."
values={{ itemCount: items.length }}
/>
</EuiDelayRender>
</caption>
</EuiScreenReaderOnly>
);
Expand Down
68 changes: 68 additions & 0 deletions src/components/delay_render/delay_render.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Component } from 'react';

interface EuiDelayRenderProps {
delay: number;
}

interface EuiDelayRenderState {
delay: number;
toggle: boolean;
}

export class EuiDelayRender extends Component<
EuiDelayRenderProps,
EuiDelayRenderState
> {
static defaultProps = {
delay: 500,
};

private delayID: number | undefined;
private toBeDelayed: boolean = false;

constructor(props: EuiDelayRenderProps) {
super(props);
this.state = {
delay: this.props.delay,
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
toggle: false,
};
}

shouldUpdate() {
this.setState(({ toggle }) => ({ toggle: !toggle }));
}

startDelaying = () => {
window.clearTimeout(this.delayID);
this.toBeDelayed = true;
this.delayID = window.setTimeout(this.stopDelaying, this.state.delay);
};
stopDelaying = () => {
window.clearTimeout(this.delayID);
this.toBeDelayed = false;
this.shouldUpdate();
};

componentDidMount() {
this.toBeDelayed = true;
}
shouldComponentUpdate(
nextProps: EuiDelayRenderProps,
nextState: EuiDelayRenderState
) {
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
if (this.toBeDelayed) {
this.startDelaying();
}
return true;
}
componentWillUnmount() {
this.stopDelaying();
}
componentDidUpdate() {
this.toBeDelayed = true;
}

render() {
return !this.toBeDelayed ? this.props.children : null;
}
}
1 change: 1 addition & 0 deletions src/components/delay_render/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { EuiDelayRender } from './delay_render';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`FieldValueToggleFilter render - active 1`] = `
<EuiFilterButton
aria-pressed="true"
color="text"
grow={true}
hasActiveFilters={true}
Expand All @@ -15,6 +16,7 @@ exports[`FieldValueToggleFilter render - active 1`] = `

exports[`FieldValueToggleFilter render - active negated - custom negated name 1`] = `
<EuiFilterButton
aria-pressed="true"
color="text"
grow={true}
hasActiveFilters={true}
Expand All @@ -28,6 +30,7 @@ exports[`FieldValueToggleFilter render - active negated - custom negated name 1`

exports[`FieldValueToggleFilter render - active negated 1`] = `
<EuiFilterButton
aria-pressed="true"
color="text"
grow={true}
hasActiveFilters={true}
Expand All @@ -41,6 +44,7 @@ exports[`FieldValueToggleFilter render - active negated 1`] = `

exports[`FieldValueToggleFilter render 1`] = `
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
exports[`TermToggleGroupFilter render - active 1`] = `
Array [
<EuiFilterButton
aria-pressed="true"
color="text"
grow={true}
hasActiveFilters={true}
iconSide="right"
key="field_value_toggle_filter_item_0"
noDivider={true}
onClick={[Function]}
type="button"
withNext={true}
>
Kibana
</EuiFilterButton>,
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
noDivider={false}
onClick={[Function]}
type="button"
withNext={false}
Expand All @@ -32,23 +36,27 @@ Array [
exports[`TermToggleGroupFilter render - active negated - custom negated name 1`] = `
Array [
<EuiFilterButton
aria-pressed="true"
color="text"
grow={true}
hasActiveFilters={true}
iconSide="right"
key="field_value_toggle_filter_item_0"
noDivider={true}
onClick={[Function]}
type="button"
withNext={true}
>
-Kibana
</EuiFilterButton>,
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
noDivider={false}
onClick={[Function]}
type="button"
withNext={false}
Expand All @@ -61,23 +69,27 @@ Array [
exports[`TermToggleGroupFilter render - active negated 1`] = `
Array [
<EuiFilterButton
aria-pressed="true"
color="text"
grow={true}
hasActiveFilters={true}
iconSide="right"
key="field_value_toggle_filter_item_0"
noDivider={true}
onClick={[Function]}
type="button"
withNext={true}
>
Not Kibana
</EuiFilterButton>,
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
noDivider={false}
onClick={[Function]}
type="button"
withNext={false}
Expand All @@ -90,23 +102,27 @@ Array [
exports[`TermToggleGroupFilter render 1`] = `
Array [
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_0"
noDivider={true}
onClick={[Function]}
type="button"
withNext={true}
>
Kibana
</EuiFilterButton>,
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
noDivider={false}
onClick={[Function]}
type="button"
withNext={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`IsFilter render 1`] = `
<EuiFilterButton
aria-pressed="false"
color="text"
grow={true}
hasActiveFilters={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class FieldValueToggleFilter extends Component {
<EuiFilterButton
onClick={onClick}
hasActiveFilters={hasActiveFilters}
aria-pressed={hasActiveFilters ? 'true' : 'false'}
>
{name}
</EuiFilterButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export class FieldValueToggleGroupFilter extends Component {
key={key}
onClick={onClick}
hasActiveFilters={active}
noDivider={!isLastItem}
aria-pressed={active ? 'true' : 'false'}
withNext={!isLastItem}
>
{name}
Expand Down
1 change: 1 addition & 0 deletions src/components/search_bar/filters/is_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class IsFilter extends Component {
<EuiFilterButton
onClick={onClick}
hasActiveFilters={hasActiveFilters}
aria-pressed={hasActiveFilters ? 'true' : 'false'}
>
{name}
</EuiFilterButton>
Expand Down