I am using the latest Dev version with the fontawesome icons. I set up a block and fill in the ones that I want then save it. Everything works great until I go to edit it at which point everything under platforms except for Youtube vanishes.

Thoughts? Suggestions?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Christopher Riley created an issue. See original summary.

cbeier’s picture

Do you use a adblocker extension (or similar, like uBlock) in your browser?

Christopher Riley’s picture

Actually I do use adblock plus but it is disabled on the site.

cbeier’s picture

Because, often adblocker will hide the social media icons.

Anonymous’s picture

I believe I am having a similar issue. In my case, I can configure the block when I initially use "Place block". However, if I go to edit the block, all options except for Drupal are removed.

I am not using an adblocker, and I have also tested this in Chrome using incognito mode with no extensions being loaded.

cbeier’s picture

Hmmm, I have no idea what the problem might be. In my work and test instances I don't have the behavior.

What for php version are you using and is there any error messages?

dddbbb’s picture

Same issue here. No ad blocker in use. PHP 7.0.16.

smaz’s picture

Yup, same issue - very easy to reproduce:

1. Install module
2. Add new "Social Media Links" block to a region.
3. Configure block to include 1 or more social accounts. No need to play with any other config.
4. Save new block.
5. Edit said block (either via blocks admin UI or contextual link - doesn't matter)
6. Platforms listed in the edit screen will be only 1: YouTube.
7. Rendered block will still display platforms as per your original configuration.

The reason:

The platforms were all saved with a weight of -10.
SocialMediaLinksBlock::getPlatforms loops through the platforms, and builds an array keyed by weight so that it can be sorted.
Because of the weights all being -10, each loop through the platforms just overwrites one key, and just leaves Youtube at the end.

Will see if I can fix.

smaz’s picture

Status: Active » Needs review
FileSize
3.39 KB

Patch attached. I've tested this with both existing & new blocks.

The issue:

Caused by https://www.drupal.org/node/2873603.

The default maximum weight range of a weight field is -10 to 10.

Because the default was being set to 100, this was outside of that range & so the default value was then set to the first option in the list, -10.

As mentioned, SocialMediaLinksBlock::getPlatforms set the key of an array to be the weight. All having -10, you ended up with just one option.

To fix this, I've:

* Changed SocialMediaLinksBlock::getPlatforms to add a #weight property to each platform, then sort on this. This means that duplicate weights won't cause this issue again.
* Kept a note of what the highest weight is, added the number of platforms to this & set this as the maximum delta for the weight field.
* Because each platform has a #weight property, we can use that rather than `$this->getPlatformWeight($platform_id, $default_weight);` every time we want to know the weight.

dddbbb’s picture

@smaz I recognise those reproduction steps! ಥ_ಥ

smaz’s picture

Apologies - meant to say!

Credit to @danbohea for providing me the steps to reproduce this :)

cbeier’s picture

Title: Vanishing Config » Problem with sorting of platforms in block configuration (default sort is out of range)
Status: Needs review » Needs work

Yes, I have today catch a similar problem in a new feature implementation for this module (commit). So I can port the solution from this location also to this form.

#9: For the weight sort we can use the default Drupal callbacks from class: Drupal\Component\Utility\SortArray

cbeier’s picture

Component: User interface » Code
Priority: Normal » Critical
cbeier’s picture

Status: Needs work » Needs review
FileSize
7.94 KB

@smaz Thank your for your work and explanation. I have your patch refactored and adjusted to my developments from the last days.

New patch is attached. Feel free to test it. :)

I will commit and create a new release asap.

dddbbb’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #14 works as expected for me. Thanks all.

  • cbeier committed 5ab71b1 on 8.x-2.x
    Issue #2878942 by cbeier, smaz: Problem with sorting of platforms in...
cbeier’s picture

Status: Reviewed & tested by the community » Fixed

I have committed the last patch to the 8.x-2.x branch.

I will create a new stable release latest tomorrow (25.05.2017) including this fix.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.