Skip to content

Commit

Permalink
Fix click on now in DateFilterControl (apache#4265)
Browse files Browse the repository at this point in the history
When clicking on `now` or the infinity sign, the popover closes but the
value doesn't show in the label as expected.
  • Loading branch information
mistercrunch committed Jan 24, 2018
1 parent 4b89577 commit d4eb08e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Expand Up @@ -69,9 +69,8 @@ export default class DateFilterControl extends React.Component {
setType(type) {
this.setState({ type });
}
setValue(val) {
this.setState({ type: 'free', free: val });
this.close();
setValueAndClose(val) {
this.setState({ type: 'free', free: val }, this.close);
}
setDatetime(dttm) {
this.setState({ dttm: dttm.format().substring(0, 19) });
Expand Down Expand Up @@ -175,13 +174,15 @@ export default class DateFilterControl extends React.Component {
>
<Button
bsSize="small"
onClick={this.setValue.bind(this, 'now')}
className="now"
onClick={this.setValueAndClose.bind(this, 'now')}
>
now
</Button>
<Button
bsSize="small"
onClick={this.setValue.bind(this, '')}
className="clear"
onClick={this.setValueAndClose.bind(this, '')}
>
clear
</Button>
Expand Down
Expand Up @@ -42,6 +42,14 @@ describe('DateFilterControl', () => {
expect(wrapper.state().num).to.equal('90');
}, 10);
});
it('sets now and closes', () => {
const label = wrapper.find('.now').first();
label.simulate('click');
setTimeout(() => {
expect(wrapper.state().free).to.equal('now');
expect(wrapper.find('.popover')).to.have.length(0);
}, 10);
});
it('renders 2 dimmed sections', () => {
const label = wrapper.find('.label').first();
label.simulate('click');
Expand Down

0 comments on commit d4eb08e

Please sign in to comment.