@webitel/ui-sdk 24.8.33 → 24.8.34

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": "@webitel/ui-sdk",
3
- "version": "24.8.33",
3
+ "version": "24.8.34",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -43,8 +43,6 @@
43
43
  </template>
44
44
 
45
45
  <script setup>
46
- import { ref, watch } from 'vue';
47
-
48
46
  const props = defineProps({
49
47
  options: {
50
48
  type: Array,
@@ -78,7 +76,6 @@
78
76
  'update:visible'
79
77
  ]);
80
78
 
81
-
82
79
  function handleOptionClick({ option, index, hide }) {
83
80
  emit('click', { option, index });
84
81
  hide();
@@ -29,9 +29,10 @@
29
29
 
30
30
  <script setup>
31
31
  import { autoPlacement, autoUpdate, flip, offset, shift, useFloating } from '@floating-ui/vue';
32
- import { onMounted, ref, watch } from 'vue';
32
+ import { onMounted, onBeforeUnmount, ref, watch } from 'vue';
33
33
  import { useTooltipTriggerSubscriptions } from './_internals/useTooltipTriggerSubscriptions.js';
34
34
  import WtTooltipFloating from './_internals/wt-tooltip-floating.vue';
35
+ import debounce from '../../scripts/debounce.js';
35
36
 
36
37
  const props = defineProps({
37
38
  visible: {
@@ -75,12 +76,24 @@ const showTooltip = (event = {}) => {
75
76
  isVisible.value = true;
76
77
  event.usedByTooltip = true; // https://github.com/Akryum/floating-vue/blob/main/packages/floating-vue/src/components/Popper.ts#L884
77
78
  emitVisibilityChange();
79
+ setScrollListener();
78
80
  };
79
81
 
80
82
  const hideTooltip = (event = {}) => {
81
- if (event.usedByTooltip) return;
83
+ if (!isVisible.value || event.usedByTooltip) return;
82
84
  isVisible.value = false;
83
85
  emitVisibilityChange();
86
+ removeScrollListener();
87
+ };
88
+ const handleScroll = debounce(() => {
89
+ hideTooltip();
90
+ }, 100);
91
+
92
+ const setScrollListener = () => {
93
+ window.addEventListener('scroll', handleScroll, true);
94
+ };
95
+ const removeScrollListener = () => {
96
+ window.removeEventListener('scroll', handleScroll, true);
84
97
  };
85
98
 
86
99
  // https://floating-ui.com/docs/misc#clipping
@@ -114,6 +127,10 @@ watch(() => props.visible, (value) => {
114
127
  onMounted(() => {
115
128
  if (props.visible) showTooltip();
116
129
  });
130
+
131
+ onBeforeUnmount( () => {
132
+ removeScrollListener()
133
+ })
117
134
  </script>
118
135
 
119
136
  <style lang="scss">