Olivero's: The header is showing odd behavior when the search bar is opened.

Steps to reproduce:

1. Scroll down to the bottom.
2. Open the search bar in the header.
3. Click on the blue cross sign in the header to close the header.
4. Now it will close the header and open it at the same time.

Adding screen recording for the same.

Comments

Gauravmahlawat created an issue. See original summary.

gauravvvv’s picture

Can be seen on Live preview.
https://tugboat-aqrmztryfqsezpvnghut1cszck2wwasr.tugboat.qa/

Steps to reproduce.

See the screen recording for reference.

sakthivel m’s picture

Status: Active » Needs review
StatusFileSize
new1.85 KB

#3 Please review the patch

kishor_kolekar’s picture

Assigned: Unassigned » kishor_kolekar
kishor_kolekar’s picture

Assigned: kishor_kolekar » Unassigned
mherchel’s picture

I haven't reviewed the code yet, but good catch on finding this bug!

kiran.kadam911’s picture

Status: Needs review » Needs work

Patch #3 failed to apply.

@mherchel As per my finding this issue is because when we click on the cross sign it's focusing and scrolling window vertically to top at same amount and as per header functionality when we reach to top or header it getting open again as per the functionality.

Code core/themes/olivero/js/scripts.es6.js:

// If header is pinned open and a header element gains focus, scroll to the
// top of the page to ensure that the header elements can be seen.
    document
      .querySelector('#site-header__inner')
      .addEventListener('focusin', () => {
        if (isDesktopNav() && !stickyHeaderIsEnabled()) {
          const header = document.querySelector('#header');
          const headerNav = header.querySelector('#header-nav');
          const headerMargin = header.clientHeight - headerNav.clientHeight;
          if (window.scrollY > headerMargin) {
            window.scrollTo(0, headerMargin);
          }
        }
      });

Maybe we can stop the window scroll on focus-in OR Please suggest here what we can do best to resolve this.

Thanks!

sakthivel m’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 KB

#8 Please verify the patch

sakthivel m’s picture

StatusFileSize
new1.36 KB

#9 Recreated Patch

chetanbharambe’s picture

Assigned: Unassigned » chetanbharambe
chetanbharambe’s picture

StatusFileSize
new334.92 KB
new219.46 KB

Verified and tested patch #9.
Patch applied successfully and looks good to me.

Testing Steps:
# Goto: Appearance
# Apply Olivero theme
# Click on Hamberger menu -> Click on the search icon in the header
# scroll down to the bottom.
# click on the cross sign in the header to close the header
# User should not see header opened once click on the cross sign.

Looks good to me.
Can be a move to RTBC
Please refer attached screenshots for Before and After patch

chetanbharambe’s picture

Assigned: chetanbharambe » Unassigned
Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: 3209871.9.patch, failed testing. View results

abhijith s’s picture

StatusFileSize
new6.24 MB
new7.01 MB

Applied patch #9 and it works fine.

Before patch:
before

After patch:
after

gauravvvv’s picture

Status: Needs work » Reviewed & tested by the community

Random test fail. Moving to RTBC

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

Could someone test this with IE 11? Based on https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo, IE 11 doesn't support ScrollToOptions.

gauravvvv’s picture

StatusFileSize
new11.21 MB

I tested this on IE 11 by browser stack.

The header doesn't collapse. see the video, I have attached.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

CasseyWaldo’s picture

Issue summary: View changes

While trying to reproduce the problem, I noticed that the first and second steps were reversed. I updated the issue summary accordingly.

stonemason78980’s picture

Issue summary: View changes

Specified the steps to include which cross sign to press.

CasseyWaldo’s picture

I applied the patch and it only half fixed the issue. When the blue x button is clicked, the header is closed but the browser scrolled to the top.

Agnesh Tank’s picture

Status: Needs review » Needs work

Tried to apply the patch but gave some issue related to Java script , Below is the error I got on terminal when tried to apply the 3209871.9.patch on my local.

hence moving back to status: Needs Work

Error :
www-data@5cc8de3f7567:/app$ git apply -v 3209871.9.patch
Checking patch core/themes/olivero/js/scripts.es6.js...
error: while searching for:
const header = document.querySelector('#header');
const headerNav = header.querySelector('#header-nav');
const headerMargin = header.clientHeight - headerNav.clientHeight;
if (window.scrollY > headerMargin) {
window.scrollTo(0, headerMargin);
}
}
});
error: patch failed: core/themes/olivero/js/scripts.es6.js:155
error: core/themes/olivero/js/scripts.es6.js: patch does not apply
Checking patch core/themes/olivero/js/scripts.js...
error: while searching for:
var header = document.querySelector('#header');
var headerNav = header.querySelector('#header-nav');
var headerMargin = header.clientHeight - headerNav.clientHeight;

if (window.scrollY > headerMargin) {
window.scrollTo(0, headerMargin);
}
}
});
error: patch failed: core/themes/olivero/js/scripts.js:109
error: core/themes/olivero/js/scripts.js: patch does not apply

gauravvvv’s picture

@Agnesh Tank since the patch is passing Drupal CI then there’re no chances of failure. Please update your local setup. And don’t change the status to NW when patch have already passed CI. Thanks

paulocs’s picture

I don't see any problem to move it to NW if the patch can't be applied.
In fact the patch needs a re-roll and work must be done so @Agnesh Tank is right to change the status to NW.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

StatusFileSize
new1.35 KB

New patch.

paulocs’s picture

Assigned: paulocs » Unassigned

If the page is scrolled to the top when the menu is closed why it shouldn't be displayed?
If we want that the menu is not displayed the page should not be scrolled to the top when the menu is closed.
So I agree with @cassey.waldo that the patch fixes half of the problem and that is why the issue is with status NW.

mherchel’s picture

Status: Needs work » Closed (duplicate)

Closing this in lieu of #3226785: Olivero: Wide search form should close on blur, which will resolve this issue.