New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with inputs and textareas inside of draggable component #178
Comments
This is caused by the registration of the |
Thanks for reporting! I'm glad to accept a PR fixing this. I have two requirements:
|
Same bug with |
In the next three weeks I'm going to be busy and I don't have the time for fixing this. |
Was looking into this. If I comment out the entire @gaearon do you know if there's a specific use case or setup for why the event needs to be handled at all? IE10? Different setup from |
Will see if I can look into it. Need to figure out a way to set up a simple test case for IE9. |
I think |
@gaearon Yeah that was a good example to use, thanks. A few notes:
Unsure how you want to handle this. Without resorting to UA checking, I don't know that there's a great way to deal with this and it seems to me like it's adding functionality to support an unofficially supported browser that's breaking good browsers which may end up digging a maintenance hole. But that's all my opinion. Regardless, there's a workaround to this issue that also solves other issues. |
Removing the event listener for |
Fixed by 0a36033.
This is HTML5 drag and drop API issue in Safari. Nothing we can do about it. |
The fix for this issue was released in |
Confirmed that Ctrl/Cmd-A works in |
I see this is not fixed, create a new issue? |
Elements with contentEditable set inside a draggable parent container wouldn't allow me to select text or interact with them in any way. After some digging, I found this bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=170139 It appears Chrome has since fixed the issue. Safari's behavior can be fixed in the meantime with CSS:
|
Summary: **Summary** DraftEditors that lived inside draggable parents were useless in Safari. Now they work. Solution found here: react-dnd/react-dnd#178 (comment) **Test Plan** Use the fiddle in #1326 with the updated version. For a quick n dirty, just add this to the stylesheet: `div[contenteditable="true"] { user-select: text;}` Closes #1356 Differential Revision: D5901625 fbshipit-source-id: 7d3797286e4040575b9b5503c776bff1e29b67a9
@trevorsmith This is still not fixing the Firefox's behaviour. Do you know any workaround for Firefox? |
@rahul1995 - I just found out a solution: just store a ref to the draggable DOM node and when user focuses input/textarea set draggable attribute to const Test = () => {
const ref = useRef(null);
const [focused, setFocused] = useState(false);
const [_, drag] = useDrag({ item: { type: 'test' } });
useEffect(() => {
if (ref.current) {
ref.current.setAttribute('draggable', !focused);
}
}, [focused]);
return drag(
<textarea ref={ref} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}></textarea>
);
}; This should do the trick for Firefox 😉 |
Summary: **Summary** DraftEditors that lived inside draggable parents were useless in Safari. Now they work. Solution found here: react-dnd/react-dnd#178 (comment) **Test Plan** Use the fiddle in #1326 with the updated version. For a quick n dirty, just add this to the stylesheet: `div[contenteditable="true"] { user-select: text;}` Closes facebookarchive/draft-js#1356 Differential Revision: D5901625 fbshipit-source-id: 7d3797286e4040575b9b5503c776bff1e29b67a9
Have you considered making a PR? This is a fairly big issue on Strapi when entering data and happens on Chrome too. |
To be honest I didn't, because I didn't know where to start - if anyone can point me in the right direction I'm happy to work on the issue 👍 |
All good, digging in more I saw that your fix has to be applied outside the scope of the react-dnd core. Was trying to apply it to this ref, but the Strapi contrib process was not working correctly on my M1 machine 😅 There may be a way to use the logic you propose on nested elements and have it bubble up to the draggable ref so we fix it at the React-dnd level for all to make benefit, but we'd have to dig in more to see how that would work. |
This is a vanilla JS issue, not a React issue. Programmatically focusing the input element when its clicked on fixes the issue. |
@sean-mcclure - so you think a solution like this should work? const Test = () => {
const [_, drag] = useDrag({ item: { type: 'test' } });
return drag(
<textarea onClick={(e) => e.target.focus()}></textarea>
);
}; Why is this a vanilla JS issue and is it reported anywhere in Gecko (Firefox) or Blink (Chromium based browsers)? |
A year later almost, but I for some reason found a now soon-to-be-deprecated repo react-sortable-hoc way more intuitive to work with. Have more troubles setting the new repo up for some reason 🤔 Am I the only one ? Are we exchanging flexibility for the ease of use? |
Summary: **Summary** DraftEditors that lived inside draggable parents were useless in Safari. Now they work. Solution found here: react-dnd/react-dnd#178 (comment) **Test Plan** Use the fiddle in #1326 with the updated version. For a quick n dirty, just add this to the stylesheet: `div[contenteditable="true"] { user-select: text;}` Closes facebookarchive/draft-js#1356 Differential Revision: D5901625 fbshipit-source-id: 7d3797286e4040575b9b5503c776bff1e29b67a9
This is not documented very well, but if you add the class name No other solutions solved my issue.
|
I investigate some problems when placing
<input>
and<textarea>
elements inside of draggable component,cmd+A
orCtrl+A
shortcuts doesn't work for input or textarea (but selecting text withShift + Arrows
still works)My draggable component looks like,
The text was updated successfully, but these errors were encountered: