|
299 | 299 | const android = /android/i.test(navigator.userAgent);
|
300 | 300 |
|
301 | 301 | !ios && !android && describe('keyboard navigation', () => {
|
302 |
| - before(done => { |
| 302 | + beforeEach((done) => { |
303 | 303 | const fixtureElements = fixture('default');
|
304 | 304 | grid = fixtureElements[0];
|
305 | 305 | focusable = fixtureElements[1];
|
| 306 | + focusable.focus(); |
306 | 307 |
|
307 | 308 | scroller = grid.$.scroller;
|
308 | 309 | header = grid.$.header;
|
309 | 310 | body = grid.$.items;
|
310 | 311 | footer = grid.$.footer;
|
311 | 312 |
|
| 313 | + grid.items = ['foo', 'bar']; |
312 | 314 | grid._observer.flush();
|
313 |
| - |
314 |
| - flushGrid(grid); |
315 |
| - |
316 |
| - flush(done); |
317 |
| - }); |
318 |
| - |
319 |
| - beforeEach(() => { |
320 |
| - if (!grid.parentElement) { |
321 |
| - document.body.appendChild(grid); |
322 |
| - document.body.appendChild(focusable); |
323 |
| - } |
324 |
| - |
325 |
| - // Reset side effects from tests |
326 |
| - grid.style.width = ''; |
327 |
| - grid.style.border = ''; |
328 |
| - |
329 |
| - if (grid.items[0] !== 'foo' || grid.items[1] !== 'bar') { |
330 |
| - grid.size = undefined; |
331 |
| - grid.dataProvider = undefined; |
332 |
| - grid.items = ['foo', 'bar']; |
333 |
| - flushGrid(grid); |
334 |
| - } |
335 |
| - grid.activeItem = null; |
336 |
| - grid.detailsOpenedItems = []; |
337 |
| - grid._columnTree[0].forEach(column => column.hidden = column.frozen = false); |
338 |
| - |
339 |
| - grid._focusedItemIndex = 0; |
340 |
| - grid._focusedColumnOrder = undefined; |
341 |
| - grid._resetKeyboardNavigation(); |
342 |
| - grid.removeAttribute('navigating'); |
343 |
| - focusable.focus(); |
344 | 315 | flushGrid(grid);
|
| 316 | + animationFrameFlush(done); |
345 | 317 | });
|
346 | 318 |
|
347 | 319 | describe('navigation mode', () => {
|
|
812 | 784 |
|
813 | 785 | expect(getFocusedCellIndex()).to.equal(1);
|
814 | 786 | const columnFocusedCell = grid.shadowRoot.activeElement._column;
|
815 |
| - expect(columnFocusedCell.hidden).to.be.false; |
| 787 | + expect(columnFocusedCell.hidden).not.to.be.true; |
816 | 788 | });
|
817 | 789 |
|
818 | 790 | it('should skip over hidden column with left arrow', () => {
|
|
835 | 807 |
|
836 | 808 | expect(getFocusedCellIndex()).to.equal(0);
|
837 | 809 | const columnFocusedCell = grid.shadowRoot.activeElement._column;
|
838 |
| - expect(columnFocusedCell.hidden).to.be.false; |
| 810 | + expect(columnFocusedCell.hidden).not.to.be.true; |
839 | 811 | });
|
840 | 812 |
|
841 | 813 | it('should not navigate to hidden column with right arrow', () => {
|
|
858 | 830 |
|
859 | 831 | expect(getFocusedCellIndex()).to.equal(0);
|
860 | 832 | const columnFocusedCell = grid.shadowRoot.activeElement._column;
|
861 |
| - expect(columnFocusedCell.hidden).to.be.false; |
| 833 | + expect(columnFocusedCell.hidden).not.to.be.true; |
862 | 834 | });
|
863 | 835 |
|
864 | 836 | it('should not navigate to hidden column with home', () => {
|
|
871 | 843 |
|
872 | 844 | expect(getFocusedCellIndex()).to.equal(1);
|
873 | 845 | const columnFocusedCell = grid.shadowRoot.activeElement._column;
|
874 |
| - expect(columnFocusedCell.hidden).to.be.false; |
| 846 | + expect(columnFocusedCell.hidden).not.to.be.true; |
875 | 847 |
|
876 | 848 | });
|
877 | 849 | });
|
|
0 commit comments