Comments (7)
Got you, missed that part, you are right, it works with on:pointerdown
from solid-dnd.
FYI @yonathan06 - I've released 0.4.1 now with the fix to not intercept input focus by default. I think you will likely still be better off with the drag handle for your case, but thanks for inspiring this improvement to the library.
from solid-dnd.
Yeah, we call event.preventDefault
in the sensor activator (pointerdown event) which would have the side effect of preventing focus on the input.
We did this to try and prevent confusing behaviour, but I guess we could make it configurable when setting up the sensor.
Another approach would be to not make the input itself directly draggable, but make a drag handle for it.
Although, looking at your example I'm surprised the event is intercepted by the parent which the handler is on and the input doesn't receive it. 🤔 Might have to take a closer look when back at my laptop.
from solid-dnd.
If I remove the event.preventDefault
call then we end up with a poor experience as dragging the object around causes things like text selection on the page. But we could potentially address that by intercepting those events after the drag has actually activated.
I'll have a look into that as a general improvement here.
However, a drag handle approach might be a better solution for you as you would still end up with potentially confusing behaviour in some cases -> someone trying to drag select text in the input would actually start dragging the input. I added a drag handle example to https://solid-dnd.com/#examples if it helps.
from solid-dnd.
Oh, and if you don't actually need the input to contribute to the drag activation (and still be focusable etc) you can intercept the pointerdown event and stop it propagating from the input.
<li use:sortable>
<input type="text" on:pointerdown={(event) => event.stopPropagation()} />
</li>
from solid-dnd.
Thank you @martinpengellyphillips for the detailed response.
stopPropagation
didn't do the trick, but adding an explicit drag handler following your example (instead of having the whole element draggable) works :)
Can see here: https://stackblitz.com/edit/solid-vite-zwawhq?file=src%2Findex.tsx
Maybe it is worth mentioning it in the docs? to use a specific drag handler when has nested inputs?
it looks like createEffect
is not triggered when the store changes. Not sure if the DND causes it or something else, need to check
from solid-dnd.
No problem - glad you got to a solution.
I'm curious why stopPropagation
didn't work for you though - I made the same change in your example and it worked for me:
https://stackblitz.com/edit/solid-vite-yaf9nn?file=src/index.tsx
Note that you need to do on:pointerdown
rather than onpointerdown
(see the :
). This is because the use:
directive has to set up non-delegated event handlers whereas Solid uses delegated event handlers by default.
from solid-dnd.
Related Issues (20)
- Arbitrary drag move don't work with latest SolidJS version HOT 2
- How to use custom elements in a `SortableProvider` and not the `<Sortable/>` component. HOT 2
- Lag spike when adding many droppables HOT 2
- Component won't drop off until mouse click HOT 2
- Any way to dynamically disable sorting? HOT 4
- Uncaught TypeError: useDragDropContext is not a function or its return value is not iterable at createPointerSensor HOT 23
- console.warn in production HOT 4
- Sortable Objects HOT 2
- How to get pointer coordinate in CollisionDetector HOT 1
- Scrolling when nearing top/bottom of droppable container / sortable container. HOT 1
- Sortable with Draghandle HOT 4
- Placeholder at the beginning of a drag HOT 1
- createDraggable and createDroppable are not reactive HOT 2
- Conditionally Prevent Drag HOT 1
- Draggable SVG shape moves faster than pointer HOT 4
- Unable to load data dynamically. Please help HOT 2
- Recompute layouts on remove
- Access state and actions from callback handlers
- Get current droppable on onDragMove HOT 1
- Only the text is visible on the dragged element HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solid-dnd.