- Issue created by @joehuggans
- 🇬🇧United Kingdom joehuggans Harrogate, UK
Apologies I have made a bit of a dogs dinner of this issue description.
I just want to report however that the following is working for me, I can turn off the setting for BOTH 1st and 2st level paragraphs.
I don't know enough about this module to feel comfortable making a MR on this, and I don't think adding the library here is probably correct.
In summary, the getThirdPartySetting method was not correct, I changed it from
$widget->getThirdPartySetting('paragraphs_ee', 'paragraphs_ee', 'drag_drop')
to
$widget->getThirdPartySetting('paragraphs_ee', 'paragraphs_ee')
I then checked for the 'drag_drop' key value in the returned value, and I add the class 'drag-drop-buttons'.
I am adding the "paragraphs_ee/paragraphs_ee.drag_drop" library outside of the if statement because it doesn't seem to work on an AJAX call (when the nested paragraph is opened.)
public static function registerWidgetFeatures(array &$elements, ParagraphsWidget $widget): void { $elements['#attached']['library'][] = 'paragraphs_ee/paragraphs_ee.drag_drop'; if ($settings = $widget->getThirdPartySetting('paragraphs_ee', 'paragraphs_ee')) { if (isset($settings['drag_drop']) && $settings['drag_drop']) { $elements['#attached']['drupalSettings']['paragraphs_ee']['widgetTitle'] = $widget->getSetting('title'); foreach (Element::children($elements) as $key) { $elements[$key]['top']['#attributes']['class'][] = 'drag-drop-buttons'; } } } }
- cd51d9b7 committed on 10.0.x
Issue #3479390 by joe huggans: Can't switch off "Show arrows for drag...
- cd51d9b7 committed on 10.0.x
- 🇩🇪Germany stborchert
Thanks a lot! The call to
->getThirdPartySettings()
was totally wrong, indeed. I fixed this based on your suggestion. Automatically closed - issue fixed for 2 weeks with no activity.