Skip to content

Commit b0960bd

Browse files
samiyacdevtools-frontend-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
[AICodeCompletion] Fix Enter keypress behavior to be similar to Tab
This CL also fixes a bug which appears while editing value field and getting a suggestion because of which the user had to press Tab/Enter one additional time. Bug: 502459959 Change-Id: I3ac81aa8fb62c4f6569828ab14ef9eb4247a794e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7806813 Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Auto-Submit: Samiya Caur <samiyac@chromium.org>
1 parent 7ce315a commit b0960bd

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

front_end/panels/elements/StylePropertiesSection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,7 @@ export class StylePropertiesSection {
907907
return;
908908
}
909909
const sourceTreeElement = this.closestPropertyForEditing(this.#activeAiSuggestion.cssProperty.index);
910-
if (!(sourceTreeElement instanceof StylePropertyTreeElement) ||
911-
sourceTreeElement.property !== this.#activeAiSuggestion.cssProperty) {
910+
if (!(sourceTreeElement instanceof StylePropertyTreeElement)) {
912911
return;
913912
}
914913
return sourceTreeElement;

front_end/panels/elements/StylesSidebarPane.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,14 +1918,18 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
19181918
return;
19191919
}
19201920
break;
1921-
case 'Enter':
1921+
case 'Enter': {
19221922
if (keyboardEvent.shiftKey) {
19231923
return;
19241924
}
19251925
// Accept any available autocompletions and advance to the next field.
1926-
this.tabKeyPressed();
1926+
const handled = this.tabKeyPressed();
1927+
if (this.aiCodeCompletionProvider && handled) {
1928+
event.consume(true);
1929+
}
19271930
keyboardEvent.preventDefault();
19281931
return;
1932+
}
19291933
case 'Escape':
19301934
if (this.#handleEscape(keyboardEvent)) {
19311935
return;

0 commit comments

Comments
 (0)