Skip to content

fix: complete iOS scroll lock cleanup and body style restoration #29

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

Merged
merged 1 commit into from
Jul 1, 2025

Conversation

wh1teee
Copy link
Owner

@wh1teee wh1teee commented Jul 1, 2025

Summary

  • Fixes remaining issue where top: 0 style remained on body element after bottom sheet closes on iOS
  • Improves style restoration logic to properly handle both inline and computed styles
  • Adds explicit cleanup for externally modified properties

Technical Details

This commit addresses a subtle bug in the scroll lock restoration logic:

Problem: After closing bottom sheet on iOS, body.style.top would remain set to 0px instead of being properly removed.

Root Cause: The restoration logic was not properly distinguishing between properties that should be removed vs. restored when no original inline style existed.

Solution:

  1. Improved Property Removal Logic: When originalInlineValue === '', we now properly remove the property entirely using removeProperty()
  2. Enhanced External Modification Handling: Added explicit cleanup for properties that were modified by external libraries during our lock period
  3. Cleaner State Management: Ensures body element returns to its exact original state after scroll unlock

Test Plan

  • Verified type checking passes
  • Verified linting passes
  • Manual testing shows proper body style cleanup on iOS
  • Confirms compatibility with existing MUI conflict resolution

This completes the scroll lock conflict resolution system, ensuring robust cleanup in all scenarios.

- Fix issue where top: 0 remained on body element after bottom sheet closes on iOS
- Improve style restoration logic to properly remove inline styles when no original value existed
- Add explicit handling for externally modified properties to prevent style conflicts
- Ensures clean body state restoration in all scenarios
@wh1teee wh1teee changed the base branch from main to develop July 1, 2025 21:49
@wh1teee wh1teee merged commit 40bd171 into develop Jul 1, 2025
4 checks passed
Copy link

github-actions bot commented Jul 1, 2025

🎉 This PR is included in version 4.0.0-beta.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant