Problem/Motivation

Olivero is a theme created for accessibility, it would be great if the theme can integrate a button to go back to the top of the page. Websites often have long pages, this functionality becomes essential.

Steps to reproduce

Proposed resolution

Remaining tasks

See the tags

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3250234

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

zenimagine created an issue. See original summary.

kostyashupenko’s picture

That's a very good idea! @mherchel what do you think? For sure if/after validation it needs design first

mherchel’s picture

I'm definitely not opposed to it

kostyashupenko’s picture

Issue tags: +Needs design

@jwitkowski79 probably you can quickly suggest something so we can moving forward :)
Not sure if it should be separate issue or we can do everything right here

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gauravvvv’s picture

Status: Active » Needs review
StatusFileSize
new3.67 KB

I have added back to top button. Please review

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs screenshots, +Needs tests

Think we should have screenshots added to the issue summary.

Also seems like a feature that should have some kind of test coverage.

zenimagine’s picture

Hi, I just tested the patch, it works well, but needs some improvement.

When the page is at the top, the back button should disappear and appear only when you start scrolling the page.

zenimagine’s picture

StatusFileSize
new170.68 KB

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ahsannazir made their first commit to this issue’s fork.

ahsannazir’s picture

Status: Needs work » Needs review
kanchan bhogade’s picture

StatusFileSize
new88.23 KB
new103.54 KB

Hi
I've tested MR 8872 on Drupal 11
The MR is applied cleanly...

For no page scroll, there is No back-to-top button as expected, and when the page scrolls, the back-to-top button appears.

Attaching SS for reference
RTBC+1

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Seems all the tags are still needed. Also forgot issue summary update from before

zenimagine’s picture

hi, I found the website below which has a button to go up to the top of the page. It's great because when you scroll the page, it displays around the arrow the length of the page. Can you add an animation for the length of the page (a circle like on the website below):

https://planb.network/courses

ahsannazir’s picture

Status: Needs work » Needs review
chandansha’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.43 MB

I've tested MR 8872 with the help of View live preview link.
I verify the button is working and progress bar show around the button.
i attached the video for refference.
I move it to RTBC.
THANKS!!

mherchel’s picture

Status: Reviewed & tested by the community » Needs work

Left some general comments. We should also move this to a single directory component. It's a perfect use case.

zenimagine’s picture

Nice work. For the animation, how will you handle the infinite scrolling pages? Maybe by disabling the feature?

mherchel’s picture

I created a new branch using SDC and CSS only (using scroll animations).

Right now the scroll stuff only works on Chromium. The main functionality works on all browsers.

That being said, I think we might still want to use Intersection Observer so that the show/hide works also works on all browsers.

quietone’s picture

Title: Add the functionality back to the top of the page » Add 'back to top' of the page functionality
Issue summary: View changes

Trying for a better title. On scanning I kept thinking this was a regression.

mherchel’s picture

Status: Needs work » Needs review

The 3250234-back-to-top-mikes-sdc-branch above is ready for review. I added a JS fallback for older browsers and fixed some linting.

Note the scroll progress only works in Chromium as progressive enhancement. I don't want to add a scroll event, which has the potential to slow down the browser.

@ehsann_95 I see you're still putting in a bit of effort on the other branch. You're welcome to continue to do so, but there's still quite of work to be done. You're welcome to review the new MR, which should be a bit closer to complete.

ahsannazir’s picture

@mherchel . I will move my branch to hidden. I'll review the MR and see what can i do to move it furhter. Thanks!

ahsannazir changed the visibility of the branch 3250234-add-the-functionality to hidden.

hritick’s picture

Status: Needs review » Needs work
StatusFileSize
new377.49 KB
new23.25 MB
new3.94 MB

I have tested the Merge Request !8932 and after testing following are my observations.

  • I have applied the MR as a patch and it applied with no errors and applied successfully.

  • After applying the patch, it adds the "back to top" button at the bottom right of the screen for both the browsers , firefox and chrome.

  • For chrome, while scrolling the screen around the button a progress bar was shown and it is also interactive while scrolling the page but this feature is not available for firefox.

  • One thing I would like to point out which is that, after clicking the button for scrolling back to top and when the page is at the top the button does not disappear at its own, we have to again click back on the screen and then it disappears.

  • Another thing, I am not sure whether to count it as an issue or an suggestion, the button is appearing after a certain amount of scrolling which is according to me could be reduced by a small margin.

Overall the button is working smoothly. Attaching some screen recordings for reference.

Thanks and regards.

mherchel’s picture

Thanks for the review. We also have some failing tests for some reason.

For chrome, while scrolling the screen around the button a progress bar was shown and it is also interactive while scrolling the page but this feature is not available for firefox.

Yeah, the scroll indicator uses a browser feature that's not yet available to FF. My thought is that this is not necessary for the functionality, so I consider it progressive enhancement.

One thing I would like to point out which is that, after clicking the button for scrolling back to top and when the page is at the top the button does not disappear at its own, we have to again click back on the screen and then it disappears.

Yeah, this is an accessibility requirement (WCAG 2.4.7 Focus Visible), which states as long as a control as focus, it must remain visible. I wonder if we should shift focus to something else.

hritick’s picture

hey @mherchel,

Yeah, this is an accessibility requirement (WCAG 2.4.7 Focus Visible), which states as long as a control as focus, it must remain visible. I wonder if we should shift focus to something else.

If we ignore this as of now , rest is good and ready to move forward.
RTBC+

Thanks and regards.

Anonymous’s picture

tpham1023 changed the visibility of the branch 3250234-back-to-top-mikes-sdc-branch to hidden.

Anonymous’s picture

tpham1023 changed the visibility of the branch 3250234-back-to-top-mikes-sdc-branch to active.

ramprassad made their first commit to this issue’s fork.

ahsannazir’s picture

The pipeline is failing due to PHP Unit Functional tests are failing

Fail      Other      phpunit-38.xml       0 Drupal\Tests\block_content\Function
    PHPUnit Test failed to complete; Error: PHPUnit 10.5.38 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 8.3.14
    Configuration: /builds/issue/drupal-3250234/core/phpunit.xml.dist
---- Drupal\Tests\system\Functional\System\ThemeTest ----
Status    Group      Filename          Line Function                            
--------------------------------------------------------------------------------
Fail      Other      phpunit-17.xml       0 Drupal\Tests\system\Functional\Syst
    PHPUnit Test failed to complete; Error: PHPUnit 10.5.38 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 8.3.14
    Configuration: /builds/issue/drupal-3250234/core/phpunit.xml.dist
---- Drupal\Tests\olivero\Functional\NodeTitleTest ----
Status    Group      Filename          Line Function                            
--------------------------------------------------------------------------------
Fail      Other      phpunit-67.xml       0 Drupal\Tests\olivero\Functional\Nod
    PHPUnit Test failed to complete; Error: PHPUnit 10.5.38 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 8.3.14
    Configuration: /builds/issue/drupal-3250234/core/phpunit.xml.dist
anish.a’s picture

Issue tags: -Needs screenshots

Removing Needs Screenshots

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.