Skip to content

Commit

Permalink
[bugfix] PullRefresh: ensure value change can be watched (#3719)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jul 2, 2019
1 parent 5d5bc87 commit 5b4a4cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/pull-refresh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ export default createComponent({
onTouchEnd() {
if (!this.untouchable && this.ceiling && this.deltaY) {
this.duration = this.animationDuration;

if (this.status === 'loosing') {
this.setStatus(this.headHeight, true);
this.$emit('input', true);
this.$emit('refresh');

// ensure value change can be watched
this.$nextTick(() => {
this.$emit('refresh');
});
} else {
this.setStatus(0);
}
Expand Down
7 changes: 5 additions & 2 deletions src/pull-refresh/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PullRefresh from '..';
import { mount, trigger, triggerDrag } from '../../../test/utils';
import { mount, later, trigger, triggerDrag } from '../../../test/utils';

test('change head content when pulling down', () => {
test('change head content when pulling down', async () => {
const wrapper = mount(PullRefresh, {
propsData: {
value: false
Expand Down Expand Up @@ -32,6 +32,9 @@ test('change head content when pulling down', () => {
expect(wrapper).toMatchSnapshot();

expect(wrapper.emitted('input')).toBeTruthy();
expect(wrapper.emitted('refresh')).toBeFalsy();

await later();
expect(wrapper.emitted('refresh')).toBeTruthy();

// end loading
Expand Down

0 comments on commit 5b4a4cc

Please sign in to comment.