tmort / Socialite

Other
1.68k stars 163 forks source link

Duplicate Twitter buttons #107

Open diniscorreia opened 9 years ago

diniscorreia commented 9 years ago

Twitter buttons are now being duplicated (actually, it looks like it creates and additional button for any other tweet button on the page).

Even the project's home page is showing the problem (two tweet buttons appear under Demo).

Probably some change on Twitter's end?

osvaldasvalutis commented 9 years ago

And in some cases the buttons are tripled.

joneslloyd commented 9 years ago

The same story with me

alexcasalboni commented 9 years ago

Same problem here.

Everything works fine if I remove this line inside twitterInit, which seems to create a second anchor element. In fact, the whole twitterInit function appears to be useless now. Maybe it's just a deprecated workaround?

Update: that's not it. But it unexpectedly worked fine for a couple of times.

Update2: it worked only because I used my browser debugger and stopped the script execution. Even without changing any code, this "fixes" the problem, therefore I'd assume it's some kind of race condition during the Twitter script loading. Maybe it's loaded/bound twice?

Update3: if I comment everything inside twitterActivate, it works fine. Maybe twitter is now calling window.twttr.widgets.load(); automatically by default?

joneslloyd commented 9 years ago

Hmm, that doesn't seem to be working for me.

alexcasalboni commented 9 years ago

@joneslloyd sorry, I updated my comment.

I'm fixing it on my side by removing/commenting twitterActivate, for now. My hypothesis is that Twitter is now binding the widgets automatically, and therefore calling window.twttr.widgets.load(); is not required anymore.

I'll be waiting for a more official fix.

joneslloyd commented 9 years ago

@alexcasalboni Thanks! Is that along with the whole twitterInit function removed?

I'll try this and see if it solves it :)

alexcasalboni commented 9 years ago

@joneslloyd no, twitterInit is still required otherwise the widget won't show up at all.

joneslloyd commented 9 years ago

I see, thank you.

That's actually not working for me. Now I'm getting the other social networks loading, and the unstyled ahref text of the Twitter share button (without it loading into the twitter share button).

diniscorreia commented 9 years ago

Yep, I ended up removing window.twttr.widgets.load(); to fix it. I suspect the same, it's probably being loaded automatically. Not sure if the Twitter docs changed, but right now it only mentions twttr.widgets.load() when new content is appended to the DOM.

tmort commented 9 years ago

@diniscorreia Can you provide a live link to the issue on your site? Unfortunately not seeing the issue, even on the homepage.

Here is what I am seeing: 2015-08-13_0710

alexcasalboni commented 9 years ago

@tmort maybe you have a cached version of the Twitter JS in your browser. I can see two Twitter buttons on the homepage as well.

socialite-bug
tmort commented 9 years ago

@alexcasalboni Got it. Will check out when I'm in the office later today. @diniscorreia I'll give your fix a try first - if that is the solution I'll have an update ASAP.

Thanks to all of you for creating the thread and catching this.

alexcasalboni commented 9 years ago

@tmort any update on this? Do you think our current hotfix might create problems? I mean, if Twitter decides to rollback this update, no widgets will show up at all. Can you think of any better workaround to handle both cases?

diniscorreia commented 9 years ago

@alexcasalboni not the best solution, but if you need a quick workaround that doesn't mess with the plugin, you can just use CSS to hide all the iframes inside that element except for the first child.

Kedarnath-Rothe commented 11 months ago

Please assign this issue to me