@eturnity/eturnity_reusable_components 7.8.4 → 7.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.8.4",
3
+ "version": "7.8.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -3,7 +3,6 @@
3
3
  :position="position"
4
4
  :isOpen="isOpen"
5
5
  :class="{ visible: isOpen, hidden: !isOpen }"
6
- @click.native="onOutsideClose()"
7
6
  :backdrop="backdrop"
8
7
  >
9
8
  <modal-container @click.stop>
@@ -27,7 +26,7 @@
27
26
  // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
28
27
  // This is a more flexible modal box, where the parent can decide how the body of the modal looks
29
28
  // To use:
30
- // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true">
29
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :isLoading="true" :hideClose="true">
31
30
  // <div>Data....</div>
32
31
  // </modal>
33
32
 
@@ -137,10 +136,6 @@ export default {
137
136
  required: true,
138
137
  default: false
139
138
  },
140
- preventOutsideClose: {
141
- required: false,
142
- default: false
143
- },
144
139
  isLoading: {
145
140
  required: false,
146
141
  default: false
@@ -158,20 +153,30 @@ export default {
158
153
  default: 'fixed'
159
154
  }
160
155
  },
156
+ beforeDestroy() {
157
+ window.removeEventListener('keydown', this.handleKeyDown)
158
+ },
161
159
  methods: {
162
160
  onCloseModal() {
163
161
  this.$emit('on-close')
164
162
  },
165
- onOutsideClose() {
166
- // If true, then only allow closing to come from clicking the X or wherever the onCloseModal is called
167
- if (!this.preventOutsideClose) {
168
- this.$emit('on-close')
163
+ handleKeyDown({ key }) {
164
+ if (key === 'Escape') {
165
+ this.onCloseModal()
169
166
  }
170
167
  }
171
168
  },
172
169
  watch: {
173
- isOpen: function (newVal) {
174
- document.body.style.overflow = newVal ? 'hidden' : ''
170
+ isOpen: {
171
+ immediate: true,
172
+ handler(isOpen) {
173
+ document.body.style.overflow = isOpen ? 'hidden' : ''
174
+ if (isOpen) {
175
+ window.addEventListener('keydown', this.handleKeyDown)
176
+ } else {
177
+ window.removeEventListener('keydown', this.handleKeyDown)
178
+ }
179
+ }
175
180
  }
176
181
  }
177
182
  }