(core) Fix scrolling and column title bugs

Summary:
On Firefox and Safari, setting scrollLeft to a max safe integer was
causing it to be treated as 0. It's not clear why - for now, the
scrollWidth is used instead.

Also fixes a bug where the column title popup wouldn't appear for a
new column if tab was previously used to close the same popup for
the last column.

Test Plan: Browser test.

Reviewers: JakubSerafin

Reviewed By: JakubSerafin

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D3911
This commit is contained in:
George Gevoian 2023-06-06 21:37:17 -04:00
parent 41280a31f2
commit 0b64e408b0
2 changed files with 25 additions and 3 deletions

View File

@ -733,7 +733,7 @@ GridView.prototype.renameColumn = function(index) {
}; };
GridView.prototype.scrollPaneRight = function() { GridView.prototype.scrollPaneRight = function() {
this.scrollPane.scrollLeft = Number.MAX_SAFE_INTEGER; this.scrollPane.scrollLeft = this.scrollPane.scrollWidth;
}; };
GridView.prototype.selectColumn = function(colIndex) { GridView.prototype.selectColumn = function(colIndex) {
@ -958,8 +958,13 @@ GridView.prototype.buildDom = function() {
var renameCommands = { var renameCommands = {
nextField: function() { nextField: function() {
editIndex(editIndex() + 1); if (editIndex() === v.viewFields().peekLength - 1) {
self.selectColumn(editIndex.peek()); // Turn off editing if we're on the last field.
editIndex(-1);
} else {
editIndex(editIndex() + 1);
self.selectColumn(editIndex.peek());
}
}, },
prevField: function() { prevField: function() {
editIndex(editIndex() - 1); editIndex(editIndex() - 1);

View File

@ -364,6 +364,23 @@ describe('DescriptionColumn', function() {
await revert(); await revert();
}); });
it('should reopen editor when adding new column', async () => {
// This partially worked before - there was a bug where if you pressed tab on
// the last column, and then clicked Add Column, the editor wasn't shown, and the
// auto-generated column name was used.
const revert = await gu.begin();
await doubleClickHeader('E');
await gu.sendKeys(Key.TAB);
assert.isFalse(await popupVisible());
await addColumn();
assert.isTrue(await popupVisible());
await gu.sendKeys(Key.ESCAPE);
await gu.waitForServer();
await revert();
});
it('should support basic edition on CardList', async () => { it('should support basic edition on CardList', async () => {
const mainSession = await gu.session().teamSite.login(); const mainSession = await gu.session().teamSite.login();
const api = mainSession.createHomeApi(); const api = mainSession.createHomeApi();