Skip to content

Commit

Permalink
Fix popover dismissal bug in Chrome.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Reyes committed Nov 3, 2017
1 parent 3290b90 commit e9f5843
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/v-calendar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/v-calendar.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v-calendar",
"version": "0.0.9",
"version": "0.1.0",
"description": "A clean and extendable plugin for building simple attributed calendars in Vue.js.",
"keywords": ["vue", "calendar", "highlights", "indicators"],
"homepage": "vcalendar.netlify.com",
Expand Down
1 change: 1 addition & 0 deletions src/components/CalendarPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export default {
},
data() {
return {
todayComps,
pages: [],
page_: null,
transitionDirection: '',
Expand Down
8 changes: 8 additions & 0 deletions src/components/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:class='["anchor", "direction-" + direction, "align-" + align]'
v-if='visibleDelay'>
<div
ref='popoverContent'
:class='["content", "direction-" + direction, "align-" + align]'>
<slot name='popover-content'>
<div>Popover content goes here</div>
Expand All @@ -24,6 +25,9 @@
</template>

<script>
import Vue from 'vue';
import { composedPath } from '../utils/helpers';
const POPOVER_AUTO = -1;
const POPOVER_VISIBLE = 1;
const _tapTolerance = 0;
Expand Down Expand Up @@ -102,6 +106,10 @@ export default {
this.$emit('focusin', e);
},
focusout(e) {
// Trap focus if element losing focus is nested within the popover content
if (e.target !== this.$refs.popover && composedPath(e.target).includes(this.$refs.popoverContent)) {
Vue.nextTick(() => this.$refs.popover.focus());
}
this.visible = false;
this.$emit('focusout', e);
},
Expand Down
14 changes: 14 additions & 0 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ export const getLastArrayItem = (array) => {
return array.length ? array[array.length - 1] : undefined;
};

export const composedPath = (el) => {
const path = [];
while (el) {
path.push(el);
if (el.tagName === 'HTML') {
path.push(document);
path.push(window);
return path;
}
el = el.parentElement;
}
return path;
};

export const isMobile = {
andriod() {
return navigator.userAgent.match(/Android/i);
Expand Down

0 comments on commit e9f5843

Please sign in to comment.