Bug 1867532 - Scroll selected row into view when opening thread pane context menu by keyboard. r=freaktechnik
Differential Revision: https://phabricator.services.mozilla.com/D195104 --HG-- extra : amend_source : 807182ccdea7437575006e8e6a403850559fcc1f
This commit is contained in:
Родитель
5db19f1a8a
Коммит
ea5c87a7a3
|
@ -4635,7 +4635,10 @@ var threadPane = {
|
|||
},
|
||||
|
||||
_onItemActivate(event) {
|
||||
if (gDBView.getFlagsAt(threadTree.selectedIndex) & MSG_VIEW_FLAG_DUMMY) {
|
||||
if (
|
||||
threadTree.selectedIndex < 0 ||
|
||||
gDBView.getFlagsAt(threadTree.selectedIndex) & MSG_VIEW_FLAG_DUMMY
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4863,14 +4866,19 @@ var threadPane = {
|
|||
event.target.closest(`tr[is^="thread-"]`) ||
|
||||
threadTree.getRowAtIndex(threadTree.currentIndex);
|
||||
const isMouse = event.button == 2;
|
||||
if (!isMouse && !row) {
|
||||
if (!isMouse) {
|
||||
if (threadTree.selectedIndex < 0) {
|
||||
return;
|
||||
}
|
||||
// Scroll selected row we're triggering the context menu for into view.
|
||||
threadTree.scrollToIndex(threadTree.currentIndex, true);
|
||||
row = threadTree.getRowAtIndex(threadTree.currentIndex);
|
||||
// Try again once in the next frame.
|
||||
if (!row && !retry) {
|
||||
window.requestAnimationFrame(() => this._onContextMenu(event, true));
|
||||
return;
|
||||
if (!row) {
|
||||
row = threadTree.getRowAtIndex(threadTree.currentIndex);
|
||||
// Try again once in the next frame.
|
||||
if (!row && !retry) {
|
||||
window.requestAnimationFrame(() => this._onContextMenu(event, true));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!row || gDBView.getFlagsAt(row.index) & MSG_VIEW_FLAG_DUMMY) {
|
||||
|
|
|
@ -411,12 +411,44 @@ add_task(async function testSingleMessage() {
|
|||
);
|
||||
mailContext.hidePopup();
|
||||
|
||||
// Open the menu through the keyboard on a message that is scrolled slightly
|
||||
// out of view.
|
||||
|
||||
threadTree.selectedIndex = 5;
|
||||
threadTree.scrollToIndex(threadTree.getLastVisibleIndex() + 7, true);
|
||||
await new Promise(resolve => window.requestAnimationFrame(resolve));
|
||||
Assert.equal(threadTree.currentIndex, 5, "Row 5 is the current row");
|
||||
Assert.ok(row.parentNode, "Row element should still be attached");
|
||||
Assert.greater(
|
||||
threadTree.getFirstVisibleIndex(),
|
||||
5,
|
||||
"Selected row should no longer be visible"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
threadTree,
|
||||
{ type: "contextmenu", button: 0 },
|
||||
about3Pane
|
||||
);
|
||||
await new Promise(resolve => window.requestAnimationFrame(resolve));
|
||||
await BrowserTestUtils.waitForPopupEvent(mailContext, "shown");
|
||||
Assert.greaterOrEqual(
|
||||
5,
|
||||
threadTree.getFirstVisibleIndex(),
|
||||
"Current row is greater than or equal to first visible index"
|
||||
);
|
||||
Assert.lessOrEqual(
|
||||
5,
|
||||
threadTree.getLastVisibleIndex(),
|
||||
"Current row is less than or equal to last visible index"
|
||||
);
|
||||
mailContext.hidePopup();
|
||||
|
||||
// Open the menu on a message that is scrolled out of view.
|
||||
|
||||
threadTree.scrollToIndex(200, true);
|
||||
await new Promise(resolve => window.requestAnimationFrame(resolve));
|
||||
Assert.ok(!row.parentNode, "Row element should no longer be attached");
|
||||
Assert.equal(threadTree.currentIndex, 0, "Row 0 is the current row");
|
||||
Assert.equal(threadTree.currentIndex, 5, "Row 5 is the current row");
|
||||
Assert.ok(
|
||||
!threadTree.getRowAtIndex(threadTree.currentIndex),
|
||||
"Current row is scrolled out of view"
|
||||
|
@ -431,6 +463,16 @@ add_task(async function testSingleMessage() {
|
|||
threadTree.getRowAtIndex(threadTree.currentIndex),
|
||||
"Current row is scrolled into view when showing context menu"
|
||||
);
|
||||
Assert.greaterOrEqual(
|
||||
5,
|
||||
threadTree.getFirstVisibleIndex(),
|
||||
"Current row is greater than or equal to first visible index"
|
||||
);
|
||||
Assert.lessOrEqual(
|
||||
5,
|
||||
threadTree.getLastVisibleIndex(),
|
||||
"Current row is less than or equal to last visible index"
|
||||
);
|
||||
mailContext.hidePopup();
|
||||
|
||||
Assert.ok(BrowserTestUtils.is_hidden(mailContext), "Context menu is hidden");
|
||||
|
|
Загрузка…
Ссылка в новой задаче