Skip to content

Help scroll top#33742

Merged
rdeutz merged 33 commits intojoomla:4.0-devfrom
ceford:help_scroll_top
May 14, 2021
Merged

Help scroll top#33742
rdeutz merged 33 commits intojoomla:4.0-devfrom
ceford:help_scroll_top

Conversation

@ceford
Copy link
Copy Markdown
Contributor

@ceford ceford commented May 10, 2021

Pull Request for Issue #33722 .

Summary of Changes

Added Javascript to scroll window to top on selection of Help page

Testing Instructions

Go to Administrator / Help / Start Here - Joomla! Help
Scroll down to near the bottom of the long list and click an item there

Apply patch and rebuild with npm ci

Actual result BEFORE applying this Pull Request

Something should happen, but
Nothing appears to happen because the Iframe with the new help page has been loaded out of sight.

Expected result AFTER applying this Pull Request

The page will scroll to top bringing the newly loaded Help page into view.

Documentation Changes Required

None

ceford added 28 commits October 16, 2020 14:54
removed two local html files from system
@Abernyte-Git
Copy link
Copy Markdown

I have tested this item ✅ successfully on 5348ac5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33742.

$wa = $this->document->getWebAssetManager();

$wa->addInlineScript("
document.addEventListener('DOMContentLoaded', function(event) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a js file

@joomla-cms-bot joomla-cms-bot added the NPM Resource Changed This Pull Request can't be tested by Patchtester label May 10, 2021
element.addEventListener('click', event => {
window.scroll(0,0);
});
})
Copy link
Copy Markdown
Contributor

@dgrammatiko dgrammatiko May 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify it, to:

/**
  * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  */
const helpIndex = document.getElementById('help-index');
if (helpIndex) {
  [].slice.call(helpIndex.querySelectorAll('a'))
    .map((element) => element.addEventListener('click', () => { window.scroll(0,0); }));
}

That's all the content of the file you need

@ceford
Copy link
Copy Markdown
Contributor Author

ceford commented May 10, 2021

So I moved the javascript to a file and am now looking at the build errors - not ready to retest.

@dgrammatiko
Copy link
Copy Markdown
Contributor

So I moved the javascript to a file and am now looking at the build errors - not ready to retest.

@ceford just use the snippet from #33742 (comment) should be CI friendly

@ceford
Copy link
Copy Markdown
Contributor Author

ceford commented May 10, 2021

@dgrammatiko Thanks for the snippet - used that and now waiting for the checks to finish.

@dgrammatiko
Copy link
Copy Markdown
Contributor

used that and now waiting for the checks to finish.

You need an empty line at the end

@dgrammatiko
Copy link
Copy Markdown
Contributor

one more change window.scroll(0,0); to window.scroll(0, 0);

@sandewt
Copy link
Copy Markdown
Contributor

sandewt commented May 10, 2021

I have tested this item ✅ successfully on 05bad1f

Note test instruction: rebuild js with npm ci


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33742.

@ghost
Copy link
Copy Markdown

ghost commented May 14, 2021

I have tested this item ✅ successfully on 05bad1f


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33742.

@richard67
Copy link
Copy Markdown
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33742.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 14, 2021
@richard67 richard67 added this to the Joomla 4.0 milestone May 14, 2021
@rdeutz rdeutz merged commit c3703d9 into joomla:4.0-dev May 14, 2021
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NPM Resource Changed This Pull Request can't be tested by Patchtester

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants