Commit ea080ef0 authored by Gayane Petrosyan's avatar Gayane Petrosyan Committed by Commit Bot

Fix keyboard navigation for selected tile.

As top and left change for selected tile, it doesn't align with other
tiles anymore. Therefore keyboard navigation doesn't work for selected
tile. This CL searches for the next tile taking into account the
position of the parentElement which doesn't change when the tile is
selected.

screencast:
https://drive.google.com/file/d/1i4CeDhe3LIc-6VntqiCFoK55HT1kbNWm/view?usp=sharing

Bug: 989221
Change-Id: I917467b524460ea0d31c1b74ef228a6313264126
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1727718
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682939}
parent a74ab98e
......@@ -624,14 +624,13 @@ customize.richerPicker_getNextTile = function(deltaX, deltaY, current) {
const container = customize.richerPicker_selectedSubmenu.menu;
const tiles = Array.from(
container.getElementsByClassName(customize.CLASSES.COLLECTION_TILE));
const curIndex = tiles.indexOf(current);
container.getElementsByClassName(customize.CLASSES.COLLECTION_TILE_BG));
let nextIndex = tiles.indexOf(current.parentElement);
if (deltaX != 0) {
return tiles[curIndex + deltaX];
nextIndex += deltaX;
} else if (deltaY != 0) {
let nextIndex = tiles.indexOf(current);
const startingTop = current.getBoundingClientRect().top;
const startingLeft = current.getBoundingClientRect().left;
const startingTop = current.parentElement.getBoundingClientRect().top;
const startingLeft = current.parentElement.getBoundingClientRect().left;
// Search until a tile in a different row and the same column is found.
while (tiles[nextIndex] &&
......@@ -639,7 +638,9 @@ customize.richerPicker_getNextTile = function(deltaX, deltaY, current) {
tiles[nextIndex].getBoundingClientRect().left != startingLeft)) {
nextIndex += deltaY;
}
return tiles[nextIndex];
}
if (tiles[nextIndex]) {
return tiles[nextIndex].children[0];
}
return null;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment