Skip to content

Commit

Permalink
Fix delete button to properly work
Browse files Browse the repository at this point in the history
  • Loading branch information
kana committed Aug 22, 2019
1 parent 846cb3f commit 54ae169
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions components/LogPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export default {
this.deletableIndex = -1
},
onTouch (e) {
const i = parseInt(e.currentTarget.dataset.index, 10)
if (this.deletableIndex === i) {
if (this.deletableIndex !== -1) {
this.deletableIndex = -1
e.preventDefault()
}
Expand Down
9 changes: 8 additions & 1 deletion components/PageListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="right">
<font-awesome-icon icon="angle-right" size="lg" class="icon" />
</div>
<div class="delete" @click="onClick">
<div class="delete" @touchstart="onTouchStart" @click="onClick">
<font-awesome-icon icon="trash-alt" size="lg" class="icon" />
</div>
</link-list-item>
Expand Down Expand Up @@ -50,6 +50,13 @@ export default {
onClick (e) {
e.preventDefault()
this.$emit('delete')
},
onTouchStart (e) {
// This stopPropagation is necessary to prioritize PageListItem#onClick
// over LogPage#onTouch. The former deletes this item by tapping the
// delete button, while the latter cancels deletion by tapping another
// item or a non-delete-button portion of this item.
e.stopPropagation()
}
}
}
Expand Down

0 comments on commit 54ae169

Please sign in to comment.