Skip to content
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

AI Assistant: Limit popover height and fix anchorless popover #39109

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

AI Assistant: Limit popover height and fix anchorless popover
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function Highlight() {
}, [] );

const isPopoverOpen = popoverOpen && virtual;
const hasSuggestions = Boolean( suggestions?.suggestion );
const hasSuggestions = Boolean( suggestions?.suggestion ) || spellingSuggestions.length > 0;

const handleMouseEnter = () => {
setPopoverHover( true );
Expand Down Expand Up @@ -263,7 +263,7 @@ export default function Highlight() {

return (
<>
{ isPopoverOpen && (
{ isPopoverOpen && anchor?.parentElement && (
<Popover
anchor={ virtual }
placement={ feature === LONG_SENTENCES.name ? 'bottom' : 'bottom-start' }
Expand Down Expand Up @@ -316,7 +316,7 @@ export default function Highlight() {
</div>
) }
</div>
<div className="jetpack-ai-breve__bottom-container">
<div className="jetpack-ai-breve__suggestions-container">
{ feature !== SPELLING_MISTAKES.name && hasSuggestions && (
<Button variant="tertiary" onClick={ handleApplySuggestion }>
{ suggestions?.suggestion }
Expand All @@ -334,24 +334,23 @@ export default function Highlight() {
{ spellingSuggestion }
</Button>
) ) }
</div>
<div className="jetpack-ai-breve__helper">
{ feature === SPELLING_MISTAKES.name && (
<Button variant="link" onClick={ handleAddToDictionary }>
{ __( 'Add to dictionary', 'jetpack' ) }
</Button>
) }

<div className="jetpack-ai-breve__helper">
{ feature === SPELLING_MISTAKES.name && (
<Button variant="link" onClick={ handleAddToDictionary }>
{ __( 'Add to dictionary', 'jetpack' ) }
</Button>
) }

{ feature !== SPELLING_MISTAKES.name &&
( hasSuggestions
? __( 'Click on the suggestion to insert it.', 'jetpack' )
: description ) }
{ feature !== SPELLING_MISTAKES.name &&
( hasSuggestions
? __( 'Click on the suggestion to insert it.', 'jetpack' )
: description ) }

<div className="jetpack-ai-breve__helper-buttons-wrapper">
<Button variant="link" onClick={ handleIgnoreSuggestion }>
{ __( 'Ignore', 'jetpack' ) }
</Button>
</div>
<div className="jetpack-ai-breve__helper-buttons-wrapper">
<Button variant="link" onClick={ handleIgnoreSuggestion }>
{ __( 'Ignore', 'jetpack' ) }
</Button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@

&.jetpack-ai-breve__has-suggestions {
align-items: flex-start;
padding-top: 8px;
gap: 8px;

.jetpack-ai-breve__suggestions-container {
max-height: calc( 200px - 32px ); // 32px is the height of the helper buttons wrapper
overflow-y: auto;
overflow-x: hidden;
padding: 3px 0; // Space for the focus highlight
}
}

.jetpack-ai-breve__header-container {
display: flex;
width: 100%;
justify-content: space-between;
gap: 32px;
height: 40px;

.jetpack-ai-breve__title,
.jetpack-ai-breve__action {
Expand Down Expand Up @@ -75,17 +81,27 @@
padding-top: 0px;
padding-bottom: 0px;
padding-right: 0px;
height: unset;
height: 24px;

& > svg,
path {
fill: #0277a8;
}
}

.jetpack-ai-breve__loading {
height: 24px;
display: flex;
align-items: center;

svg {
margin-top: 0;
}
}
}
}

.jetpack-ai-breve__bottom-container {
.jetpack-ai-breve__suggestions-container {
display: flex;
flex-direction: column;
border-top: 1px solid #dcdcde;
Expand All @@ -101,30 +117,6 @@
}
}

.jetpack-ai-breve__helper {
padding: 4px 8px;
background-color: #f6f7f7;
white-space: nowrap;
color: #646970;
margin: 4px;
border-radius: 4px;
font-size: 12px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;

.jetpack-ai-breve__helper-buttons-wrapper {
display: flex;
gap: 16px;
}

.components-button {
padding: 0px;
color: #646970;
}
}

.components-button.is-tertiary {
color: #000000;
white-space: break-spaces;
Expand All @@ -137,5 +129,30 @@
line-height: 20px;
}
}

.jetpack-ai-breve__helper {
padding: 4px 8px;
background-color: #f6f7f7;
white-space: nowrap;
color: #646970;
margin: 4px;
border-radius: 4px;
font-size: 12px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;
width: calc( 100% - 8px );

.jetpack-ai-breve__helper-buttons-wrapper {
display: flex;
gap: 16px;
}

.components-button {
padding: 0px;
color: #646970;
}
}
}
}
Loading