Share Posted May 6 I am looking to have a form-modal presented using the Draggable plugin. However - I've been encountering an issue where the form fields are not intractable (I suspect due to the inline `style="touch-action: none;"` style that is embedded into all children of the Draggable element) My approach to get around this was to create a "handle" element, a child that acts as the point of contact when dragging the parent, so that only it's children would receive the `touch-action` attributes. Is this a sound approach? If so, I keep hitting a point where both the handle and the parent are being dragged - and transform attributes are being applied to both elements. I do not want the handle to ever change its relative position to the parent... But at the moment they're dragging, and accelerating, at different speeds Any insight would be appreciated, thank you https://codesandbox.io/s/musing-cartwright-t8x4wb?file=/src/App.tsx Link to comment Share on other sites More sharing options...
Share Posted May 6 Hi there! I was going to suggest using DragClickables - See the Pen LYgewxZ by GreenSock (@GreenSock) on CodePen Buuut it seems like React doesn't like that? paging @GreenSock to take a look, I thought it might have been a context issue but I added that and it's not playing ball?https://codesandbox.io/s/flamboyant-lake-mdg179?file=/src/App.tsx 1 Link to comment Share on other sites More sharing options...
Solution Solution Share Posted May 6 Yep, it looks like React adds an onclick handler on the root element. When you set dragClickables: false, Draggable will check to see if the element is a link, button, textarea, etc. and it'll also check to see if it's inside an element that meets any of the "clickable" criteria. One of those criteria is if the element has an onclick handler defined. So again, since React assigns one to the root element, that essentially makes everything get flagged as "clickable". I'm going to update Draggable to remove that criterion to avoid this, but in the meantime you can easily work around it using the clickableTest function: https://codesandbox.io/s/patient-fog-oqqxfo?file=/src/App.tsx const clickableTagExp = /^(?:a|input|textarea|button|select)$/i; const isClickable = (element, data) => !element || !element.getAttribute || element === document.body ? false : (data = element.getAttribute("data-clickable")) === "true" || (data !== "false" && (clickableTagExp.test(element.nodeName + "") || element.getAttribute("contentEditable") === "true")) ? true : isClickable(element.parentNode); Draggable.create(... { clickableTest: isClickable }); Does that clear things up? 3 Link to comment Share on other sites More sharing options...
Author Share Posted May 7 Thank you Jack (and Cassie!), I appreciate you both jumping in here. Yes, the const clickableTagExp = /^(?:a|input|textarea|button|select)$/i; is a great solution for me moving forward. Thanks again 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now