Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] dev from buefy:dev #30

Merged
merged 3 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Buefy Changelog

## 0.8.15

### Fixes

* Fix check whitelist on fixed sidebar
* Fix static sidebar on esc key

## 0.8.14

### New features
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "buefy",
"version": "0.8.14",
"version": "0.8.15",
"homepage": "https://buefy.org",
"description": "Lightweight UI components for Vue.js based on Bulma",
"author": "Rafael Beraldo <rafael.pimpa@gmail.com>",
Expand Down
45 changes: 32 additions & 13 deletions src/components/sidebar/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<template>
<div class="b-sidebar">
<div class="b-sidebar" @click="clickedOutside">
<div
class="sidebar-background"
v-if="overlay && isOpen"
/>
<transition :name="transitionName">
<div
v-show="isOpen"
ref="sidebarContent"
class="sidebar-content"
:class="rootClasses"
v-click-outside="clickOutside">
:class="rootClasses">
<slot />
</div>
</transition>
</div>
</template>

<script>
import clickOutside from '../../directives/clickOutside'

export default {
name: 'BSidebar',
directives: {
clickOutside
},
props: {
open: Boolean,
type: [String, Object],
Expand Down Expand Up @@ -59,7 +54,8 @@ export default {
data() {
return {
isOpen: this.open,
transitionName: null
transitionName: null,
animating: true
}
},
computed: {
Expand Down Expand Up @@ -93,6 +89,22 @@ export default {
},
isAbsolute() {
return this.position === 'absolute'
},
/**
* White-listed items to not close when clicked.
* Add sidebar content and all children.
*/
whiteList() {
const whiteList = []
whiteList.push(this.$refs.sidebarContent)
// Add all chidren from dropdown
if (this.$refs.sidebarContent !== undefined) {
const children = this.$refs.sidebarContent.querySelectorAll('*')
for (const child of children) {
whiteList.push(child)
}
}
return whiteList
}
},
watch: {
Expand All @@ -112,7 +124,9 @@ export default {
*/
keyPress(event) {
// Esc key
if (this.isOpen && event.keyCode === 27) this.cancel('escape')
if (this.isFixed) {
if (this.isOpen && event.keyCode === 27) this.cancel('escape')
}
},

/**
Expand All @@ -135,9 +149,14 @@ export default {
this.$emit('update:open', false)
},

clickOutside() {
if (this.isFixed && this.isOpen) {
this.cancel('outside')
/**
* Close fixed sidebar if clicked outside.
*/
clickedOutside(event) {
if (this.isFixed) {
if (this.whiteList.indexOf(event.target) < 0) {
this.cancel('outside')
}
}
}
},
Expand Down