mirror of
				https://github.com/gristlabs/grist-core.git
				synced 2025-06-13 20:53:59 +00:00 
			
		
		
		
	(core) Fixing bug with hiding multiple columns
Summary: Selection in GridView wasn't updated when fields were removed, and the selected column index was out of bounds. Test Plan: New test added Reviewers: JakubSerafin Reviewed By: JakubSerafin Differential Revision: https://phab.getgrist.com/D4137
This commit is contained in:
		
							parent
							
								
									8038ee881c
								
							
						
					
					
						commit
						d0318af39b
					
				@ -39,6 +39,10 @@ export class CellSelector extends Disposable {
 | 
			
		||||
    super();
 | 
			
		||||
    this.autoDispose(this.view.cursor.rowIndex.subscribe(() => this.setToCursor()));
 | 
			
		||||
    this.autoDispose(this.view.cursor.fieldIndex.subscribe(() => this.setToCursor()));
 | 
			
		||||
    const fieldsLength = this.autoDispose(ko.pureComputed(() => this.view.viewSection.viewFields().all().length));
 | 
			
		||||
    this.autoDispose(fieldsLength.subscribe((length) => {
 | 
			
		||||
      this.col.end(Math.min(this.col.end.peek(), length - 1));
 | 
			
		||||
    }));
 | 
			
		||||
    this.setToCursor();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,17 +2,33 @@ import {assert, driver} from 'mocha-webdriver';
 | 
			
		||||
import * as gu from 'test/nbrowser/gristUtils';
 | 
			
		||||
import {setupTestSuite} from 'test/nbrowser/testUtils';
 | 
			
		||||
import {DocCreationInfo} from "app/common/DocListAPI";
 | 
			
		||||
import {UserAPI} from 'app/common/UserAPI';
 | 
			
		||||
 | 
			
		||||
describe('GridView', function() {
 | 
			
		||||
  this.timeout(20000);
 | 
			
		||||
describe('GridViewBugs', function() {
 | 
			
		||||
  this.timeout('20s');
 | 
			
		||||
  const cleanup = setupTestSuite();
 | 
			
		||||
  let session: gu.Session, doc: DocCreationInfo, api;
 | 
			
		||||
  let session: gu.Session, doc: DocCreationInfo, api: UserAPI;
 | 
			
		||||
 | 
			
		||||
  it('should show tables with no columns without errors', async function() {
 | 
			
		||||
  before(async function() {
 | 
			
		||||
    session = await gu.session().login();
 | 
			
		||||
    doc = await session.tempDoc(cleanup, 'Hello.grist');
 | 
			
		||||
    api = session.createHomeApi();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // This test is for a bug where hiding multiple columns at once would cause an error in the menu.
 | 
			
		||||
  // Selection wasn't updated and the column index was out of bounds.
 | 
			
		||||
  it('should hide multiple columns without an error', async function() {
 | 
			
		||||
    await gu.selectColumnRange('A', 'B');
 | 
			
		||||
    await gu.openColumnMenu('B', 'Hide 2 columns');
 | 
			
		||||
    await gu.waitForServer();
 | 
			
		||||
    await gu.selectColumnRange('C', 'D');
 | 
			
		||||
    await gu.openColumnMenu('D', 'Hide 2 columns');
 | 
			
		||||
    await gu.waitForServer();
 | 
			
		||||
    await gu.openColumnMenu('E');
 | 
			
		||||
    await gu.checkForErrors();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should show tables with no columns without errors', async function() {
 | 
			
		||||
    // Create and open a new table with no columns
 | 
			
		||||
    await api.applyUserActions(doc.id, [
 | 
			
		||||
      ['AddTable', 'Empty', []],
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user