(core) Clicking on a link in a cell won't open the editor.

Summary:
Simple click (a click on a already focused cell) was opening the editor
even though user clicked an anchor in the cell.

Test Plan: Added test

Reviewers: georgegevoian

Reviewed By: georgegevoian

Subscribers: georgegevoian

Differential Revision: https://phab.getgrist.com/D4044
pull/684/head
Jarosław Sadziński 8 months ago
parent 2b11000457
commit be995d4857

@ -102,7 +102,10 @@ function DetailView(gristDoc, viewSectionModel) {
// We authorize single click only on the value to avoid conflict with tooltip
this.onEvent(this.viewPane, 'click', '.g_record_detail_value', function(elem, event) {
var field = this.recordLayout.getContainingField(elem, this.viewPane);
// If the click was place in a link, we don't want to trigger the single click
if (event.target?.closest("a")) { return; }
const field = this.recordLayout.getContainingField(elem, this.viewPane);
if (
this._twoLastFieldIdsSelected[0] === this._twoLastFieldIdsSelected[1]
&& !isNarrowScreen()

@ -0,0 +1,47 @@
import {assert, driver} from 'mocha-webdriver';
import * as gu from 'test/nbrowser/gristUtils';
import {cleanupExtraWindows, server, setupTestSuite} from 'test/nbrowser/testUtils';
describe('DetailView', function() {
this.timeout(20000);
cleanupExtraWindows();
const cleanup = setupTestSuite();
// Before create new document.
before(async function() {
const session = await gu.session().teamSite.login();
await session.tempNewDoc(cleanup);
await gu.sendActions([
['AddRecord', 'Table1', null, {A: 'some text', B: server.getHost()}],
]);
await gu.addNewSection('Card', 'Table1');
});
it('opens cell for editing when clicked', async () => {
const fieldA = await gu.getDetailCell('A', 1);
// Make sure the cell is not in edit mode.
assert.equal(await fieldA.getText(), 'some text');
assert.equal(await driver.find('.test-widget-text-editor').isPresent(), false);
// Now click on the cell and make sure it is in edit mode.
await fieldA.click(); // first is to select it
await fieldA.click(); // second is to edit it
assert.equal(await driver.find('.test-widget-text-editor').isPresent(), true);
await gu.checkTextEditor('some text');
});
it('does not opens cell for editing when clicked on link', async () => {
const fieldB = await gu.getDetailCell('B', 1);
// First select the cell.
await fieldB.click();
// Now click on the link and make sure it is not in edit mode.
await fieldB.find(".test-tb-link-icon").click();
assert.equal(await fieldB.getText(), server.getHost());
await driver.sleep(100); // This click is ignored, so wait for a bit.
assert.equal(await driver.find('.test-widget-text-editor').isPresent(), false);
});
});
Loading…
Cancel
Save