Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from IBM/hotfix/calendar-next
Browse files Browse the repository at this point in the history
Prevent form submission when clicking calnedar buttons
  • Loading branch information
Snugug authored Oct 31, 2017
2 parents f7b8b41 + e88aef7 commit 193a8ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions calendar/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<!-- Calendar Header -->
<div class="calendar__header">
<!-- Previous Month -->
<button class="calendar__previous" :title="t(microcopy.previous)" @click="navigate('prev')" :aria-controls="tableID">
<button class="calendar__previous" :title="t(microcopy.previous)" @click="navigate('prev', $event)" :aria-controls="tableID">
<span class="calendar__nav">{{ t(microcopy.previous) }}</span>
</button>
<!-- Next Month -->
<button class="calendar__next" :title="t(microcopy.next)" @click="navigate('next')" :aria-controls="tableID">
<button class="calendar__next" :title="t(microcopy.next)" @click="navigate('next', $event)" :aria-controls="tableID">
<span class="calendar__nav">{{ t(microcopy.next) }}</span>
</button>
<!-- Visual Calendar Month -->
Expand Down
6 changes: 5 additions & 1 deletion calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ export default {
select(e) {
let { target } = e;

e.preventDefault();

if (target.classList.contains('calendar__date')) {
target = target.parentNode;
}
Expand Down Expand Up @@ -358,7 +360,9 @@ export default {
isToday(current) {
return current.day === this.today.day && current.month === this.today.month && current.year === this.today.year;
},
navigate(dir) {
navigate(dir, e) {
e.preventDefault();

const move = {};
if (dir === 'next') {
move.month = this.current.month + 1 > 11 ? 0 : this.current.month + 1;
Expand Down

0 comments on commit 193a8ab

Please sign in to comment.