From a412c605d1383a8f7473d68abfb9b8e29c1f2a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Thu, 30 May 2019 19:12:41 +0800 Subject: [PATCH] [improvement] IndexBar: unify index dataset --- docs/markdown/changelog.zh-CN.md | 4 ++++ packages/index-bar/index.js | 15 +++++++-------- .../test/__snapshots__/demo.spec.js.snap | 2 +- .../test/__snapshots__/index.spec.js.snap | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index 373d58d89..2ad2359e0 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -21,6 +21,10 @@ - 新增`gutter`属性 - 支持`String`类型的`size`属性 +##### Search + +- 优化输入体验,输入法拼写过程中不再会触发`v-model`更新 + ##### SwipeCell - 支持自动计算`left-width`和`right-width` diff --git a/packages/index-bar/index.js b/packages/index-bar/index.js index 5b8f297c4..063b2c241 100644 --- a/packages/index-bar/index.js +++ b/packages/index-bar/index.js @@ -40,7 +40,7 @@ export default sfc({ data() { return { - activeAnchorIndex: -1 + activeAnchorIndex: null }; }, @@ -95,7 +95,7 @@ export default sfc({ const active = this.getActiveAnchorIndex(scrollTop, rects); - this.activeAnchorIndex = active; + this.activeAnchorIndex = this.indexList[active]; this.children.forEach((item, index) => { if (index === active) { item.active = true; @@ -137,11 +137,11 @@ export default sfc({ const { clientX, clientY } = event.touches[0]; const target = document.elementFromPoint(clientX, clientY); if (target) { - const { idx } = target.dataset; + const { index } = target.dataset; /* istanbul ignore else */ - if (this.touchActiveIdx !== idx) { - this.touchActiveIdx = idx; + if (this.touchActiveIndex !== index) { + this.touchActiveIndex = index; this.scrollToElement(target); } } @@ -178,11 +178,10 @@ export default sfc({ onTouchend={this.onTouchEnd} onTouchcancel={this.onTouchEnd} > - {this.indexList.map((index, idx) => ( + {this.indexList.map(index => ( {index} diff --git a/packages/index-bar/test/__snapshots__/demo.spec.js.snap b/packages/index-bar/test/__snapshots__/demo.spec.js.snap index da12ad6c0..7254b82c2 100644 --- a/packages/index-bar/test/__snapshots__/demo.spec.js.snap +++ b/packages/index-bar/test/__snapshots__/demo.spec.js.snap @@ -13,7 +13,7 @@ exports[`renders demo correctly 1`] = `
-
ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ
A
diff --git a/packages/index-bar/test/__snapshots__/index.spec.js.snap b/packages/index-bar/test/__snapshots__/index.spec.js.snap index 72f3bcb52..875e11e66 100644 --- a/packages/index-bar/test/__snapshots__/index.spec.js.snap +++ b/packages/index-bar/test/__snapshots__/index.spec.js.snap @@ -2,7 +2,7 @@ exports[`custom anchor text 1`] = `
-
ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Title A