Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sticky-header): prevent negative overscroll from hiding stuck elements #11266

Conversation

jkaeser
Copy link
Member

@jkaeser jkaeser commented Dec 21, 2023

Description

Safari treats the bounce back from an "overscrolled" position as a scroll event. This can cause elements to be scrolled out of view when a user, for example, rapidly swipes to scroll to the top of the document.

Screen.Recording.2023-12-21.at.4.34.49.PM-480.mov

This PR fixes this interaction by limiting how far up the scroll is considered to be. This effectively ignores overscroll.

Screen.Recording.2023-12-21.at.4.40.06.PM-480.mov

To test

Visit the Web Components deploy preview's Dotcom Shell With L1 story in Safari, and resize the window down to the mobile breakpoint. Scroll down the page until the L0 and L1 have disappeared above the viewport, then rapidly scroll to the top of the page. When the document "bounces" back into position, both the L0 and L1 should be visible.

Changelog

Changed

  • Prevents the bounce back when scrolling beyond the top of the document from hiding stuck elements above the viewport.

…ments

Safari in particular treats the bounce back from an overscrolled position
as a scroll event. This can cause elements to be scrolled out of view when
a user, for example, rapidly swipes to scroll to the top of the document.
@jkaeser jkaeser added package: utilities Work necessary for the Carbon for IBM.com utilities package adopter: AEM used when component or pattern will be used by this adopter owner: Innovation Team used when the engineering work will be done by Hybrid Cloud with DDS engineers as consultants Masthead L0/L1 v2 used when component or pattern is part of the Mashead V2 update effort labels Dec 21, 2023
@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Dec 21, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Dec 21, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Dec 21, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Dec 21, 2023

@jkaeser jkaeser marked this pull request as ready for review December 22, 2023 13:44
@jkaeser jkaeser requested a review from a team as a code owner December 22, 2023 13:44
Copy link
Member

@andy-blum andy-blum left a comment

Choose a reason for hiding this comment

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

Tested on iOS device and works perfectly.

@andy-blum andy-blum requested review from a team, ariellalgilmore and annawen1 and removed request for a team December 22, 2023 14:40
@andy-blum
Copy link
Member

This change needs to happen in both v1 and v2 (and masthead alpha) as close to concurrently as possible. The stickyheader is called by multiple components on load and we don't want to have to account for race conditions.

@kennylam kennylam added the Ready to merge Label for the pull requests that are ready to merge label Jan 5, 2024
@kodiakhq kodiakhq bot merged commit 51015ed into carbon-design-system:feat/masthead-v2-dev Jan 5, 2024
24 of 28 checks passed
@jkaeser jkaeser deleted the fix/sticky-header-safari-scroll branch January 5, 2024 21:40
jkaeser added a commit to jkaeser/carbon-for-ibm-dotcom that referenced this pull request Jan 5, 2024
…ments (carbon-design-system#11266)

### Description

Safari treats the bounce back from an "overscrolled" position as a scroll event. This can cause elements to be scrolled out of view when a user, for example, rapidly swipes to scroll to the top of the document.

https://github.com/carbon-design-system/carbon-for-ibm-dotcom/assets/12532727/097c055e-d039-4a9b-b23d-b8e5a2100da4

This PR fixes this interaction by limiting how far up the scroll is considered to be. This effectively ignores overscroll.

https://github.com/carbon-design-system/carbon-for-ibm-dotcom/assets/12532727/344ffe1b-1354-4c3d-b485-e83039eb782c

### To test 

Visit the Web Components deploy preview's [Dotcom Shell With L1 story](https://ibmdotcom-webcomponents.s3.us-east.cloud-object-storage.appdomain.cloud/deploy-previews/11266/index.html?path=/story/components-dotcom-shell--with-l-1) in Safari, and resize the window down to the mobile breakpoint. Scroll down the page until the L0 and L1 have disappeared above the viewport, then rapidly scroll to the top of the page. When the document "bounces" back into position, both the L0 and L1 should be visible.

### Changelog

**Changed**

- Prevents the bounce back when scrolling beyond the top of the document from hiding stuck elements above the viewport. 

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
kodiakhq bot pushed a commit that referenced this pull request Jan 8, 2024
### Related Ticket(s)

none

### Description

We made some enhancements to the alpha v2 masthead after we'd integrated its branch into the main C4IBM v2 branch. This PR ports those enhancements over.

- **fix(masthead-v2): use more explicit selector in dropdown toggle** (911f802) ([Original PR](#11084))
- **feat(masthead-v2): add masthead to document flow** (e1debd8) ([Original PR](#10998))
- **feat(masthead-v2): Minimize CMApp on megamenu open** (c4a06f3) ([Original PR](#11085))
- **fix(masthead-v2): do not fail if object data does not exist** (c9609f7) ([Original PR](#11205))
- **fix(masthead-v2): ensure L1 dropdown targets exist** (fc65086) ([Original PR](#11254))
- **fix(masthead-v2): provide accessible nav label** (f183d25) ([Original PR](#11269))
- **fix(sticky-header): prevent negative overscroll from hiding stuck elements** (51015ed) ([Original PR](#11266))

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
jkaeser added a commit to jkaeser/carbon-for-ibm-dotcom that referenced this pull request Jan 8, 2024
…ments (carbon-design-system#11266)

### Description

Safari treats the bounce back from an "overscrolled" position as a scroll event. This can cause elements to be scrolled out of view when a user, for example, rapidly swipes to scroll to the top of the document.

https://github.com/carbon-design-system/carbon-for-ibm-dotcom/assets/12532727/097c055e-d039-4a9b-b23d-b8e5a2100da4

This PR fixes this interaction by limiting how far up the scroll is considered to be. This effectively ignores overscroll.

https://github.com/carbon-design-system/carbon-for-ibm-dotcom/assets/12532727/344ffe1b-1354-4c3d-b485-e83039eb782c

### To test 

Visit the Web Components deploy preview's [Dotcom Shell With L1 story](https://ibmdotcom-webcomponents.s3.us-east.cloud-object-storage.appdomain.cloud/deploy-previews/11266/index.html?path=/story/components-dotcom-shell--with-l-1) in Safari, and resize the window down to the mobile breakpoint. Scroll down the page until the L0 and L1 have disappeared above the viewport, then rapidly scroll to the top of the page. When the document "bounces" back into position, both the L0 and L1 should be visible.

### Changelog

**Changed**

- Prevents the bounce back when scrolling beyond the top of the document from hiding stuck elements above the viewport. 

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
kennylam pushed a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Mar 20, 2024
…ign-system#11183)

none

We made some enhancements to the alpha v2 masthead after we'd integrated its branch into the main C4IBM v2 branch. This PR ports those enhancements over.

- **fix(masthead-v2): use more explicit selector in dropdown toggle** (911f802) ([Original PR](carbon-design-system#11084))
- **feat(masthead-v2): add masthead to document flow** (e1debd8) ([Original PR](carbon-design-system#10998))
- **feat(masthead-v2): Minimize CMApp on megamenu open** (c4a06f3) ([Original PR](carbon-design-system#11085))
- **fix(masthead-v2): do not fail if object data does not exist** (c9609f7) ([Original PR](carbon-design-system#11205))
- **fix(masthead-v2): ensure L1 dropdown targets exist** (fc65086) ([Original PR](carbon-design-system#11254))
- **fix(masthead-v2): provide accessible nav label** (f183d25) ([Original PR](carbon-design-system#11269))
- **fix(sticky-header): prevent negative overscroll from hiding stuck elements** (51015ed) ([Original PR](carbon-design-system#11266))

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adopter: AEM used when component or pattern will be used by this adopter 👀 eyes needed Masthead L0/L1 v2 used when component or pattern is part of the Mashead V2 update effort owner: Innovation Team used when the engineering work will be done by Hybrid Cloud with DDS engineers as consultants package: utilities Work necessary for the Carbon for IBM.com utilities package Ready to merge Label for the pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants