Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I experience problems with the AddToAny module in the mobile environment due to the (apparently) obsoleted "FastClick" script, which is improperly highjacking click & touch events on my pages. See my issue there at https://www.drupal.org/node/2904094. It seems to be loaded by Adaptivetheme. Is there any solution for that? Thanks for helping me out Jeff.
<script src="https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js"></script>
Comments
Comment #2
jwkovell CreditAttribution: jwkovell commentedAssuming that the JavaScript file is not needed (I haven't checked), here's how you can remove it.
First we need to determine if the file is being added directly by your theme or if it's inherited from a base theme. You can find this out by reviewing your theme's library file (THEME_ROOT/THEME_NAME.libraries.yml).
If the file is listed there, you can just delete those lines from the library file. Clear your site's cache and you're done! If the file is not listed there, it's inherited from a base theme, and we have a few more steps.
In this case, the file in question is inherited from the at_core base theme, so we have more work to do. While you could go to at_core's library file and delete fastclick there, it's better to leave base themes alone. Instead, you can override what your theme inherits from the base theme.
Open your theme's info file (THEME_ROOT/THEME_NAME.info.yml). If you already have a section called "libraries-override", add the item(s) you want to remove there. Otherwise, create a new libraries-override section at the bottom of the file.
Note
- The exact spacing used above is important. The second and third lines should be indented with exactly 2 spaces.
- For me, removing fastclick resulted in errors until I also removed fastclick_initialize. You may need to do so as well.
Save the file, clear your site's cache, and test thoroughly.
If the files really aren't needed, perhaps Jeff can remove them from the base theme. For now, though, you have control of your own theme's library files and can add or remove them as needed.
I see that fastclick also provides a way for you to ignore specific elements. If you learn that fastclick was actually needed for something else on your site, you may need to go down the route of adding the "needsclick" class to the AddToAny button.
Comment #3
gdelver@xs4all.nl CreditAttribution: gdelver@xs4all.nl as a volunteer commented@jklovell, thanks for the tip. Very helpful I will give this a try!
Comment #4
jwkovell CreditAttribution: jwkovell commentedIt appears that fastclick.js may also have trouble with some select fields on Android phones. This cropped up on my own site just yesterday.
Rather than spend too much time figuring our why fastclick only affected some select fields and not others (it was a mix of form API, views filters and webforms forms), I just removed the fastclick.js entirely using the technique in #2.
It solved the issue with no noticeable side-effects.
Comment #5
gdelver@xs4all.nl CreditAttribution: gdelver@xs4all.nl as a volunteer commentedOk, that last part is good to hear! It's now on my list of changes to do. Thanks @jklovell.
Checked it and now works fine as far as I can see...
Comment #6
Jeff Burnz CreditAttribution: Jeff Burnz commentedI'll look into it, fastclick has/had a place, its been some time since I reviewed it's use-fullness, no against removing it.
Comment #7
Jeff Burnz CreditAttribution: Jeff Burnz commentedDecided to just remove it, times have changed!
Not sure why the commits are not showing up here yet, maybe soon.
Comment #10
Jeff Burnz CreditAttribution: Jeff Burnz commentedFinally, lol, there they are!
Comment #11
jwkovell CreditAttribution: jwkovell commentedIndeed, they are a changin. Thanks Jeff!