mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1131685, don't have the selection in the list interfere with caret movement in the search field, r=mak
This commit is contained in:
parent
ff4e1de0a1
commit
655e83681c
@ -452,6 +452,28 @@ add_task(function* dont_rollup_oncaretmove() {
|
||||
is(textbox.selectionEnd, 9, "Should have moved the caret (selectionEnd after right)");
|
||||
is(searchPopup.state, "open", "Popup should still be open");
|
||||
|
||||
// Ensure caret movement works while a suggestion is selected.
|
||||
is(textbox.popup.selectedIndex, -1, "No selected item in list");
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
is(textbox.popup.selectedIndex, 0, "Selected item in list");
|
||||
is(textbox.selectionStart, 9, "Should have moved the caret to the end (selectionStart after selection)");
|
||||
is(textbox.selectionEnd, 9, "Should have moved the caret to the end (selectionEnd after selection)");
|
||||
|
||||
EventUtils.synthesizeKey("VK_LEFT", {});
|
||||
is(textbox.selectionStart, 8, "Should have moved the caret again (selectionStart after left)");
|
||||
is(textbox.selectionEnd, 8, "Should have moved the caret again (selectionEnd after left)");
|
||||
is(searchPopup.state, "open", "Popup should still be open");
|
||||
|
||||
EventUtils.synthesizeKey("VK_LEFT", {});
|
||||
is(textbox.selectionStart, 7, "Should have moved the caret (selectionStart after left)");
|
||||
is(textbox.selectionEnd, 7, "Should have moved the caret (selectionEnd after left)");
|
||||
is(searchPopup.state, "open", "Popup should still be open");
|
||||
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {});
|
||||
is(textbox.selectionStart, 8, "Should have moved the caret (selectionStart after right)");
|
||||
is(textbox.selectionEnd, 8, "Should have moved the caret (selectionEnd after right)");
|
||||
is(searchPopup.state, "open", "Popup should still be open");
|
||||
|
||||
if (navigator.platform.indexOf("Mac") == -1) {
|
||||
EventUtils.synthesizeKey("VK_HOME", {});
|
||||
is(textbox.selectionStart, 0, "Should have moved the caret (selectionStart after home)");
|
||||
|
@ -491,6 +491,21 @@ nsAutoCompleteController::HandleKeyNavigation(uint32_t aKey, bool *_retval)
|
||||
uint32_t minResultsForPopup;
|
||||
input->GetMinResultsForPopup(&minResultsForPopup);
|
||||
if (isOpen || (mRowCount > 0 && mRowCount < minResultsForPopup)) {
|
||||
// For completeSelectedIndex autocomplete fields, if the popup shouldn't
|
||||
// close when the caret is moved, don't adjust the text value or caret
|
||||
// position.
|
||||
if (isOpen) {
|
||||
bool noRollup;
|
||||
input->GetNoRollupOnCaretMove(&noRollup);
|
||||
if (noRollup) {
|
||||
bool completeSelection;
|
||||
input->GetCompleteSelectedIndex(&completeSelection);
|
||||
if (completeSelection) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t selectedIndex;
|
||||
popup->GetSelectedIndex(&selectedIndex);
|
||||
bool shouldComplete;
|
||||
@ -530,13 +545,9 @@ nsAutoCompleteController::HandleKeyNavigation(uint32_t aKey, bool *_retval)
|
||||
}
|
||||
}
|
||||
|
||||
bool noRollup;
|
||||
input->GetNoRollupOnCaretMove(&noRollup);
|
||||
if (!noRollup) {
|
||||
// Close the pop-up even if nothing was selected
|
||||
ClearSearchTimer();
|
||||
ClosePopup();
|
||||
}
|
||||
// Close the pop-up even if nothing was selected
|
||||
ClearSearchTimer();
|
||||
ClosePopup();
|
||||
}
|
||||
// Update last-searched string to the current input, since the input may
|
||||
// have changed. Without this, subsequent backspaces look like text
|
||||
|
Loading…
Reference in New Issue
Block a user