-
Notifications
You must be signed in to change notification settings - Fork 265
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
OnClick property on FontAwesomeIcon typescript issue #196
Comments
@cuauth can you provide a reproduction of this? |
Sure,
this is the smallest reproduccion of code that i could make in my local environment |
How about a cloneable GitHub repo? That Stackblitz doesn't run locally. |
first time i run one of this, i know there's a lot of unused tools in the package json, but i took it from another project. |
@cuauth I've release |
i'll hit it this weekend, and post updates, thanks |
@robmadole It works for me, but other valid attributes (like |
Can confirm this is not working on latest version.
Results in:
|
@robmadole any news on this? |
I haven't check it out but I will do it today if that's ok with you
…On Fri, Apr 19, 2019, 4:17 AM Gytis Ramanauskas ***@***.***> wrote:
@robmadole <https://github.com/robmadole> any news on this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#196 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABMWBJZQHCO7LNYWEV3OYYTPRGS35ANCNFSM4F6RTWFA>
.
|
Same here, I had to wrap the FontAwesomeIcon with a span element to make it clickable. |
Thanks to @Plasmoxy for the tip, but it would be nice if we can get a working onClick prop. It's a little annoying to have to wrap all the icons in spans. |
I couldn't make onClick work no matter what I wrapped FontAwesomeIcon with. I was able to make it clickable ONLY when wrapping it with an anchor element, but kind of useless if onClick isn't working. I ended up using unicode instead (I needed arrows) and fudged things via CSS. |
@cuauth any news on this? |
Yeah i get the same error here too, BUT -- are you sure you really want the onClick on the icon in the first place? Wrapping it in either a button or a link is the more accessibly correct way to do this, unless you're also adding aria stuff and tabindex to the icon too. |
Yes, ultimately I ended up using a wrapper tag, BUT since in general it IS possible to add onClick to SVGs why do we need to restrict developers in the first place? |
Issue is still relevant. I had to wrap my FontAwesomeIcon in |
Is wrapping the icon in a div or a span the only way to go around this issue? Without typescript I can put a onClick handler directly on the icon. |
@fulin426 Please refer to the issue's name (it says "typescript issue"). |
@siffash Maybe I wasn't clear with my issue, it's essentially the same as the OP. Typescript is not allowing me to attach a onClick handler directly on the Fontawesome component. |
yeah thats the only workaround for typescript as far as i know. |
Unfortunately, wrapping doesn't seem to work on IE11 :( |
Maybe this issue should be re-opened. It's still throwing an error in Typescript. |
why was this issue closed? it's still an issue with current 5.11.2 |
I think this issue should be re-opened, |
PRs are welcome on this issue. We don't use Typescript so it's going to be hard for us to know if we have fixed this or not. What about this file needs to change? |
If anyone can provide a reproducible test case that we can run locally that would also help a lot. |
I think this issue is fixed as onClick is directly working on FontAwesomeIcon tag. |
We just released 0.1.9 if someone can re-test this. |
I can confirm that it's working as expected for me now. I'm using v0.1.9 |
Same here works with |
I don't see onClick props in FontAwesomeIcon. "@fortawesome/fontawesome-svg-core": "^1.2.35", |
@achievermina what do you mean that you don't see them? In you code editor? |
I can also confirm that it is working. Version |
yes, this issue can be closed |
adding Onclick property to FontAwesomeIcon gives this error in the compiler.
example:
<FaIcon onClick={this.showSettings} className={style.settingsIcon + ' ' +strIconClicked} icon="cog" />
TS2339: Property 'onClick' does not exist on type 'IntrinsicAttributes & Props'.
i needed to wrap my <FaIcon in a span with the onClick, is there a way to add onClick and other Events to FontAwesomeIcon in typescript.
Thanks
The text was updated successfully, but these errors were encountered: