Skip to content

Commit

Permalink
fix: fixes issue where dragstart would fire when pointerdown was held
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamilenkovic committed Oct 14, 2024
1 parent 433252f commit cc5ab6a
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 110 deletions.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,13 @@ function setValueAtCoordinatesUsingFindIndex(

coordinates.forEach((coords) => {
let current = obj;

for (let i = 0; i < coords.length - 1; i++) {
const index = coords[i];

current = current[index];
}

const lastIndex = coords[coords.length - 1];

current[lastIndex] = newArray;
Expand Down Expand Up @@ -750,7 +753,6 @@ export function setParentValues<T>(
initialParentValues,
values
);

if (!updatedValues) {
console.warn("No updated value found");

Expand Down Expand Up @@ -1230,6 +1232,7 @@ export function handleDragstart<T>(
const config = data.targetData.parent.data.config;

if (
touchDevice ||
!validateDragstart(data) ||
!validateDragHandle({
x: data.e.clientX,
Expand Down Expand Up @@ -1680,6 +1683,8 @@ export function handleDragend<T>(
) {
data.e.preventDefault();

data.e.stopPropagation();

if (dropped) {
dropped = false;

Expand Down
1 change: 1 addition & 0 deletions tests/.nuxt/imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export { useRouteAnnouncer } from '#app/composables/route-announcer';
export { onBeforeRouteLeave, onBeforeRouteUpdate, useLink } from 'vue-router';
export { withCtx, withDirectives, withKeys, withMemo, withModifiers, withScopeId, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, computed, customRef, isProxy, isReactive, isReadonly, isRef, markRaw, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, watch, watchEffect, watchPostEffect, watchSyncEffect, isShallow, effect, effectScope, getCurrentScope, onScopeDispose, defineComponent, defineAsyncComponent, resolveComponent, getCurrentInstance, h, inject, hasInjectionContext, nextTick, provide, defineModel, defineOptions, defineSlots, mergeModels, toValue, useModel, useAttrs, useCssModule, useCssVars, useSlots, useTransitionState, useId, useTemplateRef, useShadowRoot, Component, ComponentPublicInstance, ComputedRef, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode } from 'vue';
export { injectHead, useHead, useSeoMeta, useHeadSafe, useServerHead, useServerSeoMeta, useServerHeadSafe } from '@unhead/vue';
export { useNuxtDevTools } from '../../node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@nuxt/devtools/dist/runtime/use-nuxt-devtools';
export { definePageMeta } from '../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/pages/runtime/composables';
2 changes: 1 addition & 1 deletion tests/.nuxt/nuxt.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated by nuxi
/// <reference types="@nuxt/telemetry" />
/// <reference types="@nuxtjs/tailwindcss" />
/// <reference types="@nuxt/devtools" />
/// <reference types="@nuxt/telemetry" />
/// <reference types="nuxt" />
/// <reference path="types/app-defaults.d.ts" />
/// <reference path="types/plugins.d.ts" />
Expand Down
2 changes: 1 addition & 1 deletion tests/.nuxt/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"./imports"
],
"#app-manifest": [
"./manifest/meta/6d540a10-419a-452e-8041-e934367fc156.json"
"./manifest/meta/dev"
],
"#build": [
"."
Expand Down
2 changes: 2 additions & 0 deletions tests/.nuxt/types/imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ declare global {
const useModel: typeof import('../../../node_modules/.pnpm/[email protected][email protected]/node_modules/vue')['useModel']
const useNuxtApp: typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/nuxt')['useNuxtApp']
const useNuxtData: typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/asyncData')['useNuxtData']
const useNuxtDevTools: typeof import('../../../node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@nuxt/devtools/dist/runtime/use-nuxt-devtools')['useNuxtDevTools']
const usePreviewMode: typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/preview')['usePreviewMode']
const useRequestEvent: typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/ssr')['useRequestEvent']
const useRequestFetch: typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/ssr')['useRequestFetch']
Expand Down Expand Up @@ -293,6 +294,7 @@ declare module 'vue' {
readonly useModel: UnwrapRef<typeof import('../../../node_modules/.pnpm/[email protected][email protected]/node_modules/vue')['useModel']>
readonly useNuxtApp: UnwrapRef<typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/nuxt')['useNuxtApp']>
readonly useNuxtData: UnwrapRef<typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/asyncData')['useNuxtData']>
readonly useNuxtDevTools: UnwrapRef<typeof import('../../../node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@nuxt/devtools/dist/runtime/use-nuxt-devtools')['useNuxtDevTools']>
readonly usePreviewMode: UnwrapRef<typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/preview')['usePreviewMode']>
readonly useRequestEvent: UnwrapRef<typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/ssr')['useRequestEvent']>
readonly useRequestFetch: UnwrapRef<typeof import('../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/composables/ssr')['useRequestFetch']>
Expand Down
10 changes: 7 additions & 3 deletions tests/.nuxt/types/plugins.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ type NuxtAppInjections =
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/revive-payload.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/head/runtime/plugins/unhead.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/pages/runtime/plugins/router.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/payload.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/navigation-repaint.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/check-outdated-build.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/revive-payload.server.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/chunk-reload.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/pages/runtime/plugins/prefetch.client.js").default>
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/pages/runtime/plugins/prefetch.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/pages/runtime/plugins/check-if-page-unused.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.server.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.client.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/dev-server-logs.js").default> &
InjectionType<typeof import("../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_magicast@0_hxxfk7ycp265twoy2ueiwjc44a/node_modules/nuxt/dist/app/plugins/check-if-layout-used.js").default>

declare module '#app' {
interface NuxtApp extends NuxtAppInjections { }

interface NuxtAppLiterals {
pluginName: 'nuxt:revive-payload:client' | 'nuxt:head' | 'nuxt:router' | 'nuxt:payload' | 'nuxt:revive-payload:server' | 'nuxt:chunk-reload' | 'nuxt:global-components' | 'nuxt:prefetch'
pluginName: 'nuxt:revive-payload:client' | 'nuxt:head' | 'nuxt:router' | 'nuxt:revive-payload:server' | 'nuxt:chunk-reload' | 'nuxt:global-components' | 'nuxt:prefetch' | 'nuxt:checkIfPageUnused' | 'nuxt:checkIfLayoutUsed'
}
}

Expand Down
Loading

0 comments on commit cc5ab6a

Please sign in to comment.