WebKit Bugzilla
Attachment 358986 Details for
Bug 193098
: Web Inspector: Styles: pressing Down key on empty value field shouldn't discard completion popover
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 8.87 KB, created by
Nikita Vasilyev
on 2019-01-12 00:17:56 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Nikita Vasilyev
Created:
2019-01-12 00:17:56 PST
Size:
8.87 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 5f288247439..0e6f7ed9717 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,34 @@ >+2019-01-11 Nikita Vasilyev <nvasilyev@apple.com> >+ >+ Web Inspector: Styles: pressing Down key on empty value field shouldn't discard completion popover >+ https://bugs.webkit.org/show_bug.cgi?id=193098 >+ <rdar://problem/47016036> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Hide CompletionSuggestionsView when SpreadsheetTextField moves, e.g. by scrolling or resizing the sidebar. >+ Update CompletionSuggestionsView position after pressing Up or Down key, because SpreadsheetTextField may >+ move from wrapping text. >+ >+ * UserInterface/Views/CompletionSuggestionsView.js: >+ (WI.CompletionSuggestionsView.prototype.get scrollTop): Added. >+ (WI.CompletionSuggestionsView.prototype.set scrollTop): Added. >+ (WI.CompletionSuggestionsView.prototype.hide): >+ (WI.CompletionSuggestionsView.prototype.showUntilAnchorMoves): Removed. >+ (WI.CompletionSuggestionsView.prototype.hideWhenElementMoves): Added. >+ (WI.CompletionSuggestionsView.prototype._stopMoveTimer): Added. >+ (WI.CompletionSuggestionsView): >+ >+ * UserInterface/Views/SpreadsheetTextField.js: >+ (WI.SpreadsheetTextField.prototype.set suggestionHint): >+ (WI.SpreadsheetTextField.prototype.completionSuggestionsSelectedCompletion): >+ (WI.SpreadsheetTextField.prototype._handleKeyDownForSuggestionView): >+ (WI.SpreadsheetTextField.prototype._updateCompletions): >+ (WI.SpreadsheetTextField.prototype._showSuggestionsView): Added. >+ >+ (WI.SpreadsheetTextField.prototype._reAttachSuggestionHint): >+ Drive-by: abstract out repeating code into a private method. >+ > 2019-01-11 Matt Baker <mattbaker@apple.com> > > Web Inspector: REGRESSION: deleting an audit puts selection in a selected but invisible state >diff --git a/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js b/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js >index 30cc228e6f6..78fdb42a7f1 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/CompletionSuggestionsView.js >@@ -33,7 +33,7 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > this._preventBlur = preventBlur || false; > > this._selectedIndex = NaN; >- this._anchorBounds = null; >+ this._moveIntervalIdentifier = 0; > > this._element = document.createElement("div"); > this._element.classList.add("completion-suggestions", WI.Popover.IgnoreAutoDismissClassName); >@@ -79,6 +79,16 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > selectedItemElement.scrollIntoViewIfNeeded(false); > } > >+ get scrollTop() >+ { >+ return this._containerElement.scrollTop; >+ } >+ >+ set scrollTop(value) >+ { >+ this._containerElement.scrollTop = value; >+ } >+ > selectNext() > { > var count = this._containerElement.children.length; >@@ -158,36 +168,23 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > document.body.appendChild(this._element); > } > >- showUntilAnchorMoves(getAnchorBounds) >+ hide() > { >- this._anchorBounds = getAnchorBounds(); >- if (!this._anchorBounds) { >- this.hide(); >- return; >- } >+ this._element.remove(); >+ this._stopMoveTimer(); >+ } > >- this.show(this._anchorBounds); >+ hideWhenElementMoves(element) >+ { >+ this._stopMoveTimer(); >+ let initialClientRect = element.getBoundingClientRect(); > >- let hideWhenMoved = () => { >- let anchorBounds = getAnchorBounds(); >- if (!anchorBounds || !anchorBounds.equals(this._anchorBounds)) >+ this._moveIntervalIdentifier = setInterval(() => { >+ let clientRect = element.getBoundingClientRect(); >+ if (clientRect.x !== initialClientRect.x || clientRect.y !== initialClientRect.y) > this.hide(); >- }; >+ }, 200); > >- if (this._hideWhenMovedIdentifier) >- clearInterval(this._hideWhenMovedIdentifier); >- >- this._hideWhenMovedIdentifier = setInterval(hideWhenMoved, 200); >- } >- >- hide() >- { >- this._element.remove(); >- this._anchorBounds = null; >- if (this._hideWhenMovedIdentifier) { >- clearInterval(this._hideWhenMovedIdentifier); >- this._hideWhenMovedIdentifier = 0; >- } > } > > update(completions, selectedIndex) >@@ -253,6 +250,15 @@ WI.CompletionSuggestionsView = class CompletionSuggestionsView extends WI.Object > if (this._delegate && typeof this._delegate.completionSuggestionsClickedCompletion === "function") > this._delegate.completionSuggestionsClickedCompletion(this, itemElement.textContent); > } >+ >+ _stopMoveTimer() >+ { >+ if (!this._moveIntervalIdentifier) >+ return; >+ >+ clearInterval(this._moveIntervalIdentifier); >+ this._moveIntervalIdentifier = 0; >+ } > }; > > WI.CompletionSuggestionsView.ItemElementStyleClassName = "item"; >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >index d6e232c69c6..5f4e13cb7bd 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >@@ -74,10 +74,9 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > { > this._suggestionHintElement.textContent = value; > >- if (value) { >- if (this._suggestionHintElement.parentElement !== this._element) >- this._element.append(this._suggestionHintElement); >- } else >+ if (value) >+ this._reAttachSuggestionHint(); >+ else > this._suggestionHintElement.remove(); > } > >@@ -144,8 +143,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > > this.suggestionHint = selectedText.slice(completionPrefix.length); > >- if (this._suggestionHintElement.parentElement !== this._element) >- this._element.append(this._suggestionHintElement); >+ this._reAttachSuggestionHint(); > > if (this._delegate && typeof this._delegate.spreadsheetTextFieldDidChange === "function") > this._delegate.spreadsheetTextFieldDidChange(this); >@@ -303,6 +301,12 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > else > this._suggestionsView.selectPrevious(); > >+ // Update popover position in case text moved, e.g. started or stopped wrapping. >+ let scrollTop = this._suggestionsView.scrollTop; >+ this._showSuggestionsView(); >+ if (scrollTop) >+ this._suggestionsView.scrollTop = scrollTop; >+ > if (this._delegate && typeof this._delegate.spreadsheetTextFieldDidChange === "function") > this._delegate.spreadsheetTextFieldDidChange(this); > >@@ -391,12 +395,8 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > if (completions.length === 1) { > // No need to show the completion popover that matches the suggestion hint. > this._suggestionsView.hide(); >- } else { >- let startOffset = prefix.length - completionPrefix.length; >- this._suggestionsView.showUntilAnchorMoves(() => { >- return this._getCaretRect(startOffset); >- }); >- } >+ } else >+ this._showSuggestionsView(); > > this._suggestionsView.selectedIndex = NaN; > if (completionPrefix) { >@@ -406,6 +406,22 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > this.suggestionHint = ""; > } > >+ _showSuggestionsView() >+ { >+ let prefix = this.valueWithoutSuggestion(); >+ let completionPrefix = this._getCompletionPrefix(prefix); >+ let startOffset = prefix.length - completionPrefix.length; >+ let caretRect = this._getCaretRect(startOffset); >+ >+ // Hide completion popover when the anchor element is removed from the DOM. >+ if (!caretRect) >+ this._suggestionsView.hide(); >+ else { >+ this._suggestionsView.show(caretRect); >+ this._suggestionsView.hideWhenElementMoves(this._element); >+ } >+ } >+ > _getCaretRect(startOffset) > { > let selection = window.getSelection(); >@@ -451,4 +467,12 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > > this._element.textContent = this._element.textContent; > } >+ >+ _reAttachSuggestionHint() >+ { >+ if (this._suggestionHintElement.parentElement === this._element) >+ return; >+ >+ this._element.append(this._suggestionHintElement); >+ } > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
hi
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193098
:
358236
|
358237
|
358238
|
358986
|
358987
|
359065