vue3-extended-multiselect 1.8.4 → 1.8.6

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Patch notes
2
2
 
3
- Current `vue3-extended-multiselect` version: **1.8.4**
3
+ Current `vue3-extended-multiselect` version: **1.8.6**
4
4
 
5
5
  ***
6
6
 
@@ -319,4 +319,13 @@ Adding descriptive comments for some types in typings.
319
319
 
320
320
  ### 1.8.4 (2023-02-23)
321
321
 
322
- * Fixing bug with single select input focus.
322
+ * Fixing bug with single select input focus.
323
+
324
+ ### 1.8.5 (2023-03-07)
325
+
326
+ * Adding "resize-observer-polyfill" dev-dependency.
327
+ * Fixing bug with options wrapper resize when "toggleAppearanceSide" prop is set to "atop".
328
+
329
+ ### 1.8.6 (2023-03-07)
330
+
331
+ * fixing bug with undefined "offsetHeight" variable.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.8.4
1
+ # vue3-extended-multiselect v1.8.6
2
2
 
3
3
  ***
4
4
 
package/jest.config.js CHANGED
@@ -5,7 +5,7 @@ module.exports = {
5
5
  },
6
6
  expand: true,
7
7
  displayName: {
8
- name: "vue3-extended-multiselect 1.8.4",
8
+ name: "vue3-extended-multiselect 1.8.6",
9
9
  color: "bgGreen",
10
10
  },
11
11
  extraGlobals: [],
@@ -44,6 +44,7 @@ module.exports = {
44
44
  resetModules: true,
45
45
  resetMocks: true,
46
46
  rootDir: "./",
47
+ setupFiles: ["<rootDir>/tests/utils/mocks"],
47
48
  slowTestThreshold: 20,
48
49
  testEnvironment: "jsdom",
49
50
  testLocationInResults: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -39,6 +39,7 @@
39
39
  "babel-plugin-transform-import-meta": "^2.2.0",
40
40
  "eslint": "^7.2.0",
41
41
  "eslint-plugin-vue": "^7.0.0",
42
+ "resize-observer-polyfill": "^1.5.1",
42
43
  "typescript": "~4.1.0",
43
44
  "vue-jest": "^5.0.0-0"
44
45
  }
@@ -98,8 +98,10 @@ import {
98
98
  computed,
99
99
  defineProps,
100
100
  inject,
101
+ nextTick,
101
102
  onBeforeMount,
102
103
  onMounted,
104
+ reactive,
103
105
  ref,
104
106
  toRefs,
105
107
  } from "vue";
@@ -434,7 +436,7 @@ const setSearchPattern = inject("setSearchPattern");
434
436
  const fieldWasShown = ref(false);
435
437
  const atopWithScroll = ref(null);
436
438
  const enterIndex = ref(null);
437
- const heightFromMounted = ref(null);
439
+ const heightFromMounted = reactive({});
438
440
  const underWithScroll = ref(null);
439
441
 
440
442
  /**
@@ -685,12 +687,45 @@ const showCreateNewOptionBlock = computed(() => {
685
687
  const styles = computed(() => {
686
688
  return [
687
689
  heightFromProps.value,
688
- heightFromMounted.value,
690
+ heightFromMounted,
689
691
  atopWithScroll.value,
690
692
  underWithScroll.value
691
693
  ];
692
694
  });
693
695
 
696
+ /**
697
+ * Toggles "border-bottm-right-radius", "border-bottm-right-radius"
698
+ * and "top" css-properties of options wrapper
699
+ */
700
+ const calculateTopOffset = (afterLoading = false) => {
701
+ nextTick(() => {
702
+ if (!optionsWrapper.value) return;
703
+
704
+ const offsetHeight = optionsWrapper.value.offsetHeight;
705
+ const scrollHeight = optionsWrapper.value.scrollHeight;
706
+
707
+ if (chosenToggleAppearanceSide.value === "atop") {
708
+ if (!optionsWrapper.value) return;
709
+
710
+ if (scrollHeight > offsetHeight) {
711
+ atopWithScroll.value = {
712
+ borderTopRightRadius: 0,
713
+ };
714
+ }
715
+
716
+ if (toggleMaxHeight.value >= offsetHeight || afterLoading) {
717
+ heightFromMounted.top = `-${offsetHeight - 1}px`;
718
+ }
719
+ } else {
720
+ if (scrollHeight > offsetHeight) {
721
+ underWithScroll.value = {
722
+ borderBottomRightRadius: 0,
723
+ };
724
+ }
725
+ }
726
+ });
727
+ };
728
+
694
729
  /**
695
730
  * Restricts repeated selection of option
696
731
  * @function
@@ -1143,27 +1178,8 @@ onBeforeMount(() => {
1143
1178
  * "onMounted" hook of ExtendedMultiselectOptions component
1144
1179
  */
1145
1180
  onMounted(() => {
1146
- const offsetHeight = optionsWrapper.value.offsetHeight;
1147
- const scrollHeight = optionsWrapper.value.scrollHeight;
1148
-
1149
- if (chosenToggleAppearanceSide.value === "atop") {
1150
- if (scrollHeight > offsetHeight) {
1151
- atopWithScroll.value = {
1152
- borderTopRightRadius: 0,
1153
- };
1154
- }
1155
-
1156
- if (toggleMaxHeight.value > offsetHeight) {
1157
- heightFromMounted.value = {
1158
- top: `-${offsetHeight - 1}px`,
1159
- };
1160
- }
1161
- } else {
1162
- if (scrollHeight > offsetHeight) {
1163
- underWithScroll.value = {
1164
- borderBottomRightRadius: 0,
1165
- };
1166
- }
1167
- }
1181
+ new ResizeObserver(() => {
1182
+ calculateTopOffset();
1183
+ }).observe(optionsWrapper.value);
1168
1184
  });
1169
1185
  </script>
@@ -262,7 +262,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
262
262
 
263
263
  /**
264
264
  * @author Ridiger Daniil Dmitrievich, 2022
265
- * @version 1.8.4
265
+ * @version 1.8.6
266
266
  */
267
267
 
268
268
  const props = defineProps({
@@ -0,0 +1 @@
1
+ global.ResizeObserver = require('resize-observer-polyfill');