Skip to content

Prevented page scrolling after consent has been made#107

Merged
tg666 merged 1 commit intomainfrom
fix/settings-modal-scroll-after-consent
Apr 22, 2025
Merged

Prevented page scrolling after consent has been made#107
tg666 merged 1 commit intomainfrom
fix/settings-modal-scroll-after-consent

Conversation

@tg666
Copy link
Contributor

@tg666 tg666 commented Apr 22, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue where the page could scroll unexpectedly after giving consent via the settings modal, specifically when opened from a custom trigger element. Focus is now properly removed from the trigger to prevent unwanted scrolling.

…gs modal that was opened through an element created by the "Settings modal trigger selector" option
@tg666 tg666 added the Bugfix Fix for a knowing/reported bug. label Apr 22, 2025
@tg666 tg666 self-assigned this Apr 22, 2025
@coderabbitai
Copy link

coderabbitai bot commented Apr 22, 2025

Walkthrough

A new entry was added to the changelog documenting a fix that prevents page scrolling after user consent is given via a settings modal triggered by a specific selector. In the implementation, the click event handler for the modal trigger link now removes focus from the link before opening the settings modal, by calling link.blur(). No public APIs or exported declarations were changed.

Changes

File(s) Change Summary
CHANGELOG.md Added an unreleased changelog entry describing the fix for unwanted page scrolling after consent.
src/Ui/ModalTriggerFactory.mjs Updated the click event handler to call link.blur() before showing the settings modal.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LinkElement
    participant CookieConsentWrapper

    User->>LinkElement: Click
    LinkElement->>LinkElement: Prevent default
    LinkElement->>LinkElement: blur()
    LinkElement->>CookieConsentWrapper: showSettings(0)
Loading

Poem

A bunny hops and blurs the link,
No scrolling now, just stop and think.
The changelog notes a gentle fix,
For modal clicks and UI tricks.
Consent is clear, the page stands still—
A rabbit’s patch, with coder’s skill! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dd576f and 68b527b.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/Ui/ModalTriggerFactory.mjs (1 hunks)
🔇 Additional comments (2)
CHANGELOG.md (1)

9-10: Well-documented changelog entry.

The changelog entry clearly describes the fixed issue with sufficient context about the problem and the affected component. This follows the established format of the project's changelog and provides valuable information for users upgrading to this version.

src/Ui/ModalTriggerFactory.mjs (1)

46-50: Good fix for preventing unwanted page scrolling.

Adding link.blur() is an effective solution to prevent the browser from keeping focus on the link element after the settings modal is opened. This prevents the browser from attempting to keep the focused element in the viewport, which was causing unwanted page scrolling after consent was given.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tg666 tg666 merged commit 8790bc4 into main Apr 22, 2025
2 checks passed
@tg666 tg666 deleted the fix/settings-modal-scroll-after-consent branch April 22, 2025 09:08
@coderabbitai coderabbitai bot mentioned this pull request Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix Fix for a knowing/reported bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant