Skip to content
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

bug: ion-img should accept draggable prop #21325

Closed
magoarcano opened this issue May 18, 2020 · 8 comments · Fixed by #24781
Closed

bug: ion-img should accept draggable prop #21325

magoarcano opened this issue May 18, 2020 · 8 comments · Fixed by #24781
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@magoarcano
Copy link

This basic functionality of html should work as <img draggable="false> so we can disable the default drag option for

@ionitron-bot ionitron-bot bot added the triage label May 18, 2020
@liamdebeasi liamdebeasi added the ionitron: needs reproduction a code reproduction is needed from the issue author label May 18, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented May 18, 2020

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please provide a reproduction with the minimum amount of code required to reproduce the issue. Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

For a guide on how to create a good reproduction, see our Contributing Guide.

@ionitron-bot ionitron-bot bot removed the triage label May 18, 2020
@magoarcano
Copy link
Author

It's simple to reproduce.
I don't mean about Drag and Drop functionality. I mean that by default <img> types are draggable: (i.e. you can try to drag the avatar image in this page and you will see a shadowed copy of the image)

I made an app where the user can drag and rotate markers on an image. The experience is annoying if the image is draggable. With normal <img> tags works great. But <ion-img> doesn't work as expected.

I made demo here: https://stackblitz.com/edit/ionic-pnlxgp?file=pages%2Fhome%2Fhome.html
Steps for reproduce:
Draggable, OK:
<img src= "https://hackernoon.com/hn-images/1*nlhD6_U277a1s_VxSbH11g.jpeg">
Not Dragable: OK
<img src= "https://hackernoon.com/hn-images/1*nlhD6_U277a1s_VxSbH11g.jpeg" draggable="false">
Should not be draggable, but it is.
<img src= "https://hackernoon.com/hn-images/1*nlhD6_U277a1s_VxSbH11g.jpeg" draggable="false">

@liamdebeasi liamdebeasi added package: core @ionic/core package type: feature request a new feature, enhancement, or improvement and removed ionitron: needs reproduction a code reproduction is needed from the issue author labels May 19, 2020
@liamdebeasi liamdebeasi changed the title bug: <ion-img draggable="false"> is not working bug: ion-img should accept draggable="false" May 19, 2020
@liamdebeasi liamdebeasi changed the title bug: ion-img should accept draggable="false" bug: ion-img should accept draggable prop May 19, 2020
@liamdebeasi liamdebeasi added the help wanted a good issue for the community label May 19, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented May 19, 2020

This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.

For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.

Thank you!

@cerkiner
Copy link
Contributor

cerkiner commented Jun 3, 2020

The problem is that the browser defaults to true for <img> tag's draggable. When rendered draggable={false} in stenciljs, it won't pass draggable attribute because it evaluates the absence of an attribute as same as false. Then browser defaults to draggable="true" causing an unwanted result.

EDIT;
Unfortunately, the type of img.draggable attribute is boolean.
(JSX attribute) JSXBase.HTMLAttributes.draggable?: boolean | undefined

@cerkiner
Copy link
Contributor

cerkiner commented Jun 3, 2020

The problem is that the browser defaults to true for <img> tag's draggable. When rendered draggable={false} in stenciljs, it won't pass draggable attribute because it evaluates the absence of an attribute as same as false. Then browser defaults to draggable="true" causing an unwanted result.

EDIT;
Unfortunately, the type of img.draggable attribute is boolean.
(JSX attribute) JSXBase.HTMLAttributes.draggable?: boolean | undefined

@liamdebeasi issue mentioned here; ionic-team/stencil#2484

@simonhaenisch
Copy link
Contributor

simonhaenisch commented Jun 3, 2020

@liamdebeasi I submitted a fix for this in Stencil. So after this is out and upgrading, you'll just need to pass the draggable attribute on to the actual image tag here

https://github.com/ionic-team/ionic/blob/c7e94a1f2377bd578dd748038196453975109c20/core/src/components/img/img.tsx#L99-L106

like so:

<img
  // ....
  draggable={this.el.getAttribute('draggable') || undefined}
/>

(getAttribute returns null if the attribute isn't defined)

@cerkiner
Copy link
Contributor

cerkiner commented Jun 8, 2020

I just tested with "@stencil/core": "^1.15.0-2" and I can confirm it will be achievable after stencil upgrade.

@ionitron-bot
Copy link

ionitron-bot bot commented Mar 23, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants