sprintify-ui 0.10.48 → 0.10.49

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": "sprintify-ui",
3
- "version": "0.10.48",
3
+ "version": "0.10.49",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && vue-tsc && vite build",
@@ -49,7 +49,7 @@ import { config } from '@/index';
49
49
  import BaseAutocompleteFetch from './BaseAutocompleteFetch.vue';
50
50
  import { RawOption, SelectConfiguration } from '@/types';
51
51
  import { Size } from '@/utils/sizes';
52
- import { debounce, isObject } from 'lodash';
52
+ import { debounce, isObject, uniqueId } from 'lodash';
53
53
 
54
54
  const props = withDefaults(
55
55
  defineProps<{
@@ -107,19 +107,20 @@ const autocompleteFetch = ref<InstanceType<
107
107
  > | null>(null);
108
108
 
109
109
  const model = ref<RawOption | null>(null);
110
- const ensureModelIsFilledDebounced = debounce(ensureModelIsFilled, 100);
110
+
111
+ const ensureModelIsFilledWithRouteDebounced = debounce(ensureModelIsFilledWithRoute, 50);
111
112
 
112
113
  watch(
113
114
  () => props.currentModel,
114
- ensureModelIsFilledDebounced,
115
+ ensureModelIsFilled,
115
116
  );
116
117
 
117
118
  watch(
118
119
  () => props.modelValue,
119
- ensureModelIsFilledDebounced,
120
+ ensureModelIsFilled,
120
121
  );
121
122
 
122
- ensureModelIsFilledDebounced();
123
+ ensureModelIsFilled();
123
124
 
124
125
  function onUpdate(newModel: RawOption | null) {
125
126
  if (!newModel) {
@@ -157,10 +158,33 @@ function ensureModelIsFilled() {
157
158
  return;
158
159
  }
159
160
 
161
+ ensureModelIsFilledWithRouteDebounced();
162
+ }
163
+
164
+
165
+ let ensureModelIsFilledWithRouteLastId = null as string | number | null;
166
+
167
+ function ensureModelIsFilledWithRoute() {
168
+ if (props.modelValue == null) {
169
+ model.value = null;
170
+ return;
171
+ }
172
+
173
+ if (props.showRouteUrl == null) {
174
+ return;
175
+ }
176
+
177
+ const ensureModelIsFilledWithRouteCurrentId = uniqueId();
178
+ ensureModelIsFilledWithRouteLastId = ensureModelIsFilledWithRouteCurrentId;
179
+
160
180
  http
161
181
  .get(props.showRouteUrl(props.modelValue))
162
182
  .then((response: AxiosResponse) => {
163
183
 
184
+ if (ensureModelIsFilledWithRouteLastId !== ensureModelIsFilledWithRouteCurrentId) {
185
+ return;
186
+ }
187
+
164
188
  const data = response.data as Record<string, unknown>;
165
189
 
166
190
  if (!isObject(data)) {