Skip to content

Fix Term Widget not registering pointer events #1614

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 5 commits into from
Dec 24, 2024
Merged

Conversation

esimkowitz
Copy link
Member

@esimkowitz esimkowitz commented Dec 24, 2024

This is a bit janky. The problem is that we were placing the xterm-viewport div, which contains the scroll observer for the xterm contents, at a higher z-index than the xterm contents, meaning that the contents couldn't register any pointer events. If we don't put a z-index, though, the scroll bar can't accept pointer events. To get around this, I've added two observer divs, which control whether the contents or the viewport have pointer event priority. The first div, the term-scrollbar-show-observer, sits above where the scrollbar will be rendered. When the user hovers over it, it will cause the viewport div to move to a z-index above the contents. It will also enable a second div, the term-scrollbar-hide-observer, which sits above the viewport and the term contents, but not blocking the scrollbar. When the user hovers over this div (indicating their mouse has left the scrollbar), the viewport div is moved back to its original z-index and the hide observer is set to display: none. This gives pointer event priority back to the contents div.

This resolves an issue where the user could not click links in the terminal output.

Resolves #1357

Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces changes to the terminal view's scrollbar visibility management in both the SCSS styling (term.scss) and the React component (term.tsx). The modifications focus on implementing new observer mechanisms for scrollbar interactions within the terminal interface.

In the SCSS file, two new CSS classes are added: .term-scrollbar-show-observer and .term-scrollbar-hide-observer. These classes are positioned absolutely and have specific z-index configurations to control the scrollbar's overlay behavior. The changes also include minor reformatting of existing classes and the removal of the z-index property for the .xterm-viewport class.

The corresponding TypeScript file introduces callback functions onScrollbarShowObserver and onScrollbarHideObserver to dynamically manage the scrollbar's visibility. These functions manipulate the z-index and display properties of terminal elements to provide a more interactive user experience when scrolling through terminal content.


📜 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 4321c5f and a8b319c.

📒 Files selected for processing (1)
  • frontend/app/view/term/term.tsx (2 hunks)

🪧 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. (Beta)
  • @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.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
frontend/app/view/term/term.tsx (2)

852-857: Remove or refine console debugging statements.

While logging is useful for debugging, consider removing or converting console.log statements to a logging utility with appropriate log levels in production code. This helps maintain a clean console output in production.


865-865: Use descriptive naming for stickerConfig.

While the sticker configuration object is static, renaming it to something like "terminalStickerConfig" may enhance clarity and reduce confusion if there are multiple “config” objects in the file.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b778417 and 4321c5f.

📒 Files selected for processing (2)
  • frontend/app/view/term/term.scss (2 hunks)
  • frontend/app/view/term/term.tsx (2 hunks)
🔇 Additional comments (5)
frontend/app/view/term/term.tsx (3)

851-851: Check for null references before usage.

Since you are capturing references to DOM elements (e.g., scrollbarHideObserverRef), consider guarding against scenarios where the element might be null. Adding a simple conditional check can help avoid runtime errors if the element hasn't mounted yet.


858-863: Double-check fallback styling for termViewport.

When resetting the z-index to "auto" on pointer out, ensure there is no scenario where the terminal requires a specific default z-index other than "auto." Verify that no other elements rely on the old z-index or that "auto" doesn't inadvertently hide or surface the element in unexpected ways.


879-886: Verify observer element widths match actual scrollbar sizes.

Both observers use fixed widths (12px). If the scrollbar width changes in future design updates, these fixed values might cause a mismatch. You could dynamically calculate the observer widths or at least maintain them as SASS variables to ensure consistency.

frontend/app/view/term/term.scss (2)

39-55: Styling looks consistent.

No functional changes are introduced, and the usage of flex layout with overflow handling is consistent with other toolbar definitions.


129-146: Confirm existence of --zindex-xterm-viewport-overlay.

Ensure the custom property --zindex-xterm-viewport-overlay is defined somewhere in the codebase and has sensible defaults, especially for browsers that might not support CSS variables.

Generate this script to confirm the variable definition:

✅ Verification successful

The CSS variable --zindex-xterm-viewport-overlay is properly defined with a value of 5

The variable is defined in the codebase with a clear value and purpose (for viewport containing the scrollbar), making it safe to use in z-index calculations. The implementation in the reviewed code correctly uses this variable for layering the scrollbar observers.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the definition of --zindex-xterm-viewport-overlay across SCSS/CSS files
fd -e scss -e css --exec rg --context 5 'zindex-xterm-viewport-overlay'

Length of output: 951

@esimkowitz esimkowitz merged commit b7a5dea into main Dec 24, 2024
3 of 5 checks passed
@esimkowitz esimkowitz deleted the evan/fix-term-pointer branch December 24, 2024 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Please add hyperlink support for terminal blocks
1 participant