Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Always show highlight buttons#397

Merged
joseplayero merged 1 commit intoreorproject:mainfrom
yaodingyd:highlight
Sep 5, 2024
Merged

Always show highlight buttons#397
joseplayero merged 1 commit intoreorproject:mainfrom
yaodingyd:highlight

Conversation

@yaodingyd
Copy link
Copy Markdown
Contributor

fix #348
/claim #348

I think it might be a product decision to show the highlight utility button when texts overflows, personally I think it would be better to display at the top but open for discussion

Screen.Recording.2024-09-04.at.10.09.42.PM.mov

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request addresses the issue of the highlight utility button not displaying when highlighted text overflows the screen height, modifying the button's positioning logic in the HighlightExtension component.

  • Modified src/components/Editor/HighlightExtension.tsx to adjust button positioning when text overflows screen height
  • Introduced a conditional check top >= window.innerHeight to determine button placement
  • Set button position to 20px from top of screen when text overflows, otherwise 35px above highlighted text
  • Removed a console.log statement, improving code cleanliness
  • Potential UI/UX implications of new button positioning warrant further discussion and testing

1 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings


// Calculate the button position below the last word
const buttonTop = top - 35 // Adjust the vertical offset as needed
const buttonTop = top >= window.innerHeight ? 20 : top - 35 // Adjust the vertical offset as needed
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Consider using a constant for the 20px value for better maintainability


// Calculate the button position below the last word
const buttonTop = top - 35 // Adjust the vertical offset as needed
const buttonTop = top >= window.innerHeight ? 20 : top - 35 // Adjust the vertical offset as needed
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logic: The button might still be off-screen if the window is very short. Consider adding a minimum value check

// Calculate the button position below the last word
const buttonTop = top - 35 // Adjust the vertical offset as needed
const buttonTop = top >= window.innerHeight ? 20 : top - 35 // Adjust the vertical offset as needed
const buttonLeft = (left + right) / 2 - 190 // Position the button horizontally centered
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: The -190 offset seems arbitrary. Consider calculating this dynamically based on button width

@joseplayero joseplayero merged commit 1b1bd85 into reorproject:main Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix highlight bug in writing assistant

2 participants