- 🇧🇷Brazil carolpettirossi Campinas - SP
I'm wondering how I can provide a patch here, and any guidance would be appreciated.
Should we get a
ScrollTopCommand
into Core (9.x)? I've seen this issue https://www.drupal.org/project/drupal/issues/3300481 ✨ Move ScrollTopCommand views Ajax command to the Drupal Core Fixed that might help with this part.After getting a
ScrollTopCommand
in Core, is updating theAjaxFormHelperTrait::ajaxSubmit
the correct solution for this issue? - 🇧🇷Brazil carolpettirossi Campinas - SP
Providing a patch to fix the
scrollTop
with Ajax submission in Layout Builder. The patch attached is for 9.5.x.The approach is to override the
AjaxFormHelperTrait::ajaxSubmit
inConfigureBlockFormBase
, calling a custom/new Ajax command calledLayoutBuilderScrollTopCommand
responsible for scrolling the LB canvas to top.Before:
After:
layout - Status changed to Needs review
about 2 years ago 3:42pm 22 March 2023 - Status changed to Needs work
about 2 years ago 4:07pm 22 March 2023 The Needs Review Queue Bot → tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- last update
over 1 year ago Patch Failed to Apply - 🇩🇪Germany ammaletu Bonn, Germany
This is still happening on Drupal 10.4. I had another look at this. Some details:
- The first patch above (#17) started with its own Layout-Builder-specific scrollTop command.
- Patch #20 removed most of that command, but not everything, and used the new default ScrollTopCommand instead.
- This doesn't seem to work, or at least not reliable. I got a JavaScript error "scrollTarget.get is not a function". Line 1882 in the scrollTop function does look to me like the jQuery call is missing.
- There is a ticket trying to radically simplify the scrollTop function: https://www.drupal.org/project/drupal/issues/3478087 ✨ Modernize Drupal.ajaxCommands.scrollTop() Active
I tried both versions, but none of them worked for the first error. If I hit "Submit" a second, theird etc. time, sometimes it works and scrolls up, sometimes it scrolls up a bit and sometimes it doesn't.
Does anybody know if this is specific to Layout Builder? Scrolling on the main part of the page is controlled by the Layout Builder to stay on the block currently being edited. Could this somehow interfere with our scrolling attempts here? If I have a good idea how to fix this, I'm more than happy to provide a correct patch in an MR.