Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

added css to block pointer events #104

Merged
merged 4 commits into from
Jul 31, 2024
Merged

added css to block pointer events #104

merged 4 commits into from
Jul 31, 2024

Conversation

bkd705
Copy link
Contributor

@bkd705 bkd705 commented Jul 24, 2024

POC for blocking out events and "freezing page" by using CSS to disable pointer events

Summary by CodeRabbit

  • New Features

    • Enhanced editor mode functionality with improved setup and teardown processes.
    • Introduced style management to prevent user interactions during editing.
  • Bug Fixes

    • Improved cleanup process when exiting editor mode.

Copy link

coderabbitai bot commented Jul 24, 2024

Walkthrough

Walkthrough

The recent updates to the editor mode functionality streamline the code by introducing helper functions for setup and teardown processes. This modular approach enhances maintainability and clarity, particularly in managing user interactions and styles during editing. The addition of debugging logs also improves visibility into user actions, contributing to a more robust editing experience.

Changes

Files Change Summary
apps/mocksi-lite/content/EditMode/editMode.ts Refactored setEditorMode to use setupEditor and teardownEditor. Introduced injectStylesToBlockEvents and removeStylesToBlockEvents for managing user interaction styles during editing. Enhanced cleanup logic and added console logging for better debugging.

Poem

🐰 In the editor's cozy nook,
Functions dance with a joyful look.
Styles injected to block the chase,
While debugging logs embrace the space.
A rabbit's cheer for code refined,
A playful hop for the thoughtful mind! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
apps/mocksi-lite/content/EditMode/editMode.ts (1)

18-31: LGTM! Consider adding a comment for the console log.

The setupEditor function is well-structured. The console log for debugging is useful, but consider adding a comment to explain its purpose.

+  // Debugging: Log when styles are injected
  console.log('injecting styles');
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1273015 and 67d36d6.

Files selected for processing (1)
  • apps/mocksi-lite/content/EditMode/editMode.ts (3 hunks)
Additional comments not posted (4)
apps/mocksi-lite/content/EditMode/editMode.ts (4)

12-16: LGTM! The function changes are straightforward.

The setEditorMode function now delegates responsibilities to setupEditor and teardownEditor, enhancing modularity.


Line range hint 32-43:
LGTM! The function is well-structured.

The teardownEditor function follows a clear sequence of actions for cleanup.


239-248: LGTM! The function effectively blocks pointer events.

The injectStylesToBlockEvents function is straightforward and effectively blocks pointer events on links, buttons, and images.


250-255: LGTM! The function effectively removes the injected styles.

The removeStylesToBlockEvents function is straightforward and effectively removes the style element that blocks pointer events.

@bkd705 bkd705 marked this pull request as ready for review July 29, 2024 19:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 67d36d6 and 0201b3e.

Files selected for processing (1)
  • apps/mocksi-lite/content/EditMode/editMode.ts (3 hunks)
Additional comments not posted (5)
apps/mocksi-lite/content/EditMode/editMode.ts (5)

Line range hint 32-41:
LGTM! Verify the function calls.

The function logic is clear and well-structured.

However, ensure that all function calls to teardownEditor are correct.

Verification successful

Function call to teardownEditor is correct and located within the same file.

  • teardownEditor is called within apps/mocksi-lite/content/EditMode/editMode.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `teardownEditor`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type typescript -A 5 $'teardownEditor'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify all function calls to `teardownEditor`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg -A 5 $'teardownEditor'

Length of output: 859


250-255: LGTM! Verify the function calls.

The function logic is clear and well-structured.

However, ensure that all function calls to removeStylesToBlockEvents are correct.

Verification successful

LGTM! The function calls are correct and localized within the same file.

  • The function removeStylesToBlockEvents is defined and called within editMode.ts.
  • There are no other occurrences of this function call in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `removeStylesToBlockEvents`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type typescript -A 5 $'removeStylesToBlockEvents'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify all function calls to `removeStylesToBlockEvents`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type ts -A 5 $'removeStylesToBlockEvents'

Length of output: 955


239-248: LGTM! Verify the function calls.

The function logic is clear and well-structured.

However, ensure that all function calls to injectStylesToBlockEvents are correct.

Verification successful

LGTM! Verify the function calls.

The function injectStylesToBlockEvents is correctly defined and called within the same file apps/mocksi-lite/content/EditMode/editMode.ts.

  • Function call found at: apps/mocksi-lite/content/EditMode/editMode.ts: injectStylesToBlockEvents();
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `injectStylesToBlockEvents`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type typescript -A 5 $'injectStylesToBlockEvents'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify all function calls to `injectStylesToBlockEvents`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type ts -A 5 $'injectStylesToBlockEvents'

Length of output: 961


18-31: LGTM! Verify the function calls.

The function logic is clear and well-structured.

However, ensure that all function calls to setupEditor are correct.

Verification successful

All function calls to setupEditor are correct.

The function is only called within its defining file, ensuring localized and controlled usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `setupEditor`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type typescript -A 5 $'setupEditor'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify all function calls to `setupEditor`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type ts -A 5 $'setupEditor'

Length of output: 843


Script:

#!/bin/bash
# Description: Verify all function calls to `setupEditor` across the entire codebase.

# Test: Search for the function usage. Expect: Only valid function calls.
rg -t ts -A 5 'setupEditor'

Length of output: 839


12-16: LGTM! Verify the function calls.

The refactoring improves maintainability and readability.

However, ensure that all function calls to setEditorMode are correct.

Verification successful

Function calls to setEditorMode are correctly implemented.

The refactoring maintains the expected behavior across the codebase.

  • apps/mocksi-lite/content/Toast/EditToast.tsx
  • apps/mocksi-lite/content/ListPopup/DemoItem.tsx
  • apps/mocksi-lite/content/Toast/PlayToast.tsx
  • apps/mocksi-lite/content/Toast/HiddenToast.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `setEditorMode`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg --type typescript -A 5 $'setEditorMode'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify all function calls to `setEditorMode`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg 'setEditorMode' --glob '*.ts' -A 5

Length of output: 480


Script:

#!/bin/bash
# Description: Verify all function calls to `setEditorMode`.

# Test: Search for the function usage. Expect: Only valid function calls.
rg 'setEditorMode' -A 5

Length of output: 4353

Copy link
Contributor

@elg0nz elg0nz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

}

// blockClickableElements();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: was commenting this out intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah removed it now!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we block using the css now this function isnt necessary, ill remove the actual function in a future PR

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0201b3e and a771693.

Files selected for processing (1)
  • apps/mocksi-lite/content/EditMode/editMode.ts (4 hunks)
Additional comments not posted (5)
apps/mocksi-lite/content/EditMode/editMode.ts (5)

30-35: LGTM! Modular approach enhances maintainability.

The setEditorMode function now appropriately delegates responsibilities to setupEditor and teardownEditor, improving code modularity and maintainability.


265-274: LGTM! The function correctly blocks pointer events.

The injectStylesToBlockEvents function correctly injects a style element to block pointer events on various elements.


276-281: LGTM! The function correctly restores pointer events.

The removeStylesToBlockEvents function correctly removes the style element to restore pointer events.


Line range hint 58-67:
LGTM! Verify the function usage.

The teardownEditor function is well-structured and enhances modularity. The call to removeStylesToBlockEvents effectively restores pointer events.

Ensure that teardownEditor is correctly invoked in all relevant scenarios.

Verification successful

The teardownEditor function is invoked within the same file where it is defined (editMode.ts). This indicates that its usage is localized and seems to be correctly placed. The function is invoked as part of a larger process, likely handling the teardown of an editor.

  • File: apps/mocksi-lite/content/EditMode/editMode.ts
    • Invocation: teardownEditor(recordingId);

LGTM! The function is correctly invoked in the relevant context.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `teardownEditor` in the codebase.

# Test: Search for the function usage. Expect: Correct invocation in all scenarios.
rg --type javascript -A 5 $'teardownEditor'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify all function calls to `teardownEditor` in the codebase.

# Test: Search for the function usage. Expect: Correct invocation in all scenarios.
rg --type ts -A 5 teardownEditor

Length of output: 869


Line range hint 37-57:
LGTM! Verify the function usage.

The setupEditor function is well-structured and enhances modularity. The call to injectStylesToBlockEvents effectively blocks pointer events.

Ensure that setupEditor is correctly invoked in all relevant scenarios.

@bkd705 bkd705 merged commit 84fb6a0 into main Jul 31, 2024
3 checks passed
@bkd705 bkd705 deleted the bd-poc-pointer-events branch July 31, 2024 02:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants