Skip to content
Snippets Groups Projects

Correctly sets tabindex to 0 on move up / down buttons that are inactive....

Merged Justin Toupin requested to merge issue/layout_paragraphs-3423427:3423427-up--down into 2.0.x
5 unresolved threads

Correctly sets tabindex to 0 on move up / down buttons that are inactive. Includes a number of other related javascript optimizations.

Closes #3423427

Merge request reports

Code Quality is loading
Test summary results are being parsed

Merged by Justin ToupinJustin Toupin 11 months ago (Apr 16, 2024 5:10pm UTC)

Loading

Pipeline #148420 passed with warnings

Pipeline passed with warnings for f569c229 on 2.0.x

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
17 17 const { element, method } = uiElement;
18 18 $container[method]($(element).addClass('js-lpb-ui'));
19 19 });
20 Drupal.attachBehaviors($container[0], drupalSettings);
  • This was previously running every time a UI element was attached to the dom (i.e. for each Layout Paragraphs "add component" button, controls UI, etc.) causing behaviors to be rerun dozens of times on a single page.

  • Please register or sign in to reply
  • 106 105 * @param {jQuery} $element The builder element.
    107 106 */
    108 107 function updateMoveButtons($element) {
    109 $element.find('.lpb-up, .lpb-down').attr('tabindex', '0');
    110 $element
    111 .find(
    112 '.js-lpb-component:first-of-type .lpb-up, .js-lpb-component:last-of-type .lpb-down',
    113 )
    114 .attr('tabindex', '-1');
    108 [...$element[0].querySelectorAll('.lpb-up, .lpb-down')].forEach((el) => {
  • 171 $sibling.css({ transform: `translateY(${b}px)` });
    172 },
    173 complete() {
    174 $moveItem.css({ transform: 'none' });
    175 $sibling.css({ transform: 'none' });
    176 $sibling[method]($moveItem);
    177 $moveItem
    178 .closest(`[${idAttr}]`)
    179 .trigger('lpb-component:move', [$moveItem.attr('data-uuid')]);
    180 },
    181 },
    182 );
    183 if (distance > 50) {
    184 $('html, body').animate({ scrollTop: destScroll });
    163 // Determine if the move should be animated horizontally or vertically.
    164 const animateProp = $sibling[0].getBoundingClientRect().top == $moveItem[0].getBoundingClientRect().top
  • 530 });
    531 // Add new containers to the dragula instance.
    532 $('.js-lpb-region:not(.is-dragula-enabled)', element)
    533 .addClass('is-dragula-enabled')
    534 .get()
    535 .forEach((c) => {
    536 const drake = $(element).data('drake');
    537 drake.containers.push(c);
    538 });
    537 $element.data('drake', initDragAndDrop($element, lpbSettings));
    538 attachEventListeners($element, lpbSettings);
    539 $element.trigger('lpb-builder:init');
    539 540 });
    541
    542 // Add new containers to the dragula instance.
    543 once('is-dragula-enabled', '.js-lpb-region').forEach((c) => {
  • 501 515 Drupal.behaviors.layoutParagraphsBuilder = {
    502 516 attach: function attach(context, settings) {
    503 517 // Add UI elements to the builder, each component, and each region.
    504 $(once('lpb-ui-elements', '[data-has-js-ui-element]')).each((i, el) => {
    518 const jsUiElements = once('lpb-ui-elements', '[data-has-js-ui-element]');
  • added 1 commit

    Compare with previous version

  • added 1 commit

    • e554587f - Fixed selector for adding new containers

    Compare with previous version

  • added 1 commit

    • 34ee2962 - Check to make sure buttons exist before changing attribute

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • Justin Toupin started a merge train

    started a merge train

  • Please register or sign in to reply
    Loading