diff --git a/browser/src/control/Parts.js b/browser/src/control/Parts.js index eae36d39e8..4d3a5ecc5f 100644 --- a/browser/src/control/Parts.js +++ b/browser/src/control/Parts.js @@ -30,7 +30,7 @@ L.Map.include({ if (docLayer.isCalc()) docLayer._sheetSwitch.save(part /* toPart */); - docLayer._clearMsgReplayStore(); + docLayer._clearMsgReplayStore(true /* notOtherMsg*/); docLayer._prevSelectedPart = docLayer._selectedPart; docLayer._selectedParts = []; if (part === 'prev') { diff --git a/browser/src/layer/tile/CanvasTileLayer.js b/browser/src/layer/tile/CanvasTileLayer.js index 5928b5c946..f8dd05aeec 100644 --- a/browser/src/layer/tile/CanvasTileLayer.js +++ b/browser/src/layer/tile/CanvasTileLayer.js @@ -2873,6 +2873,7 @@ L.CanvasTileLayer = L.Layer.extend({ if (!cellViewCursorMarker) { var backgroundColor = L.LOUtil.rgbToHex(this._map.getViewColor(viewId)); cellViewCursorMarker = new CCellCursor(this._cellViewCursors[viewId].corePixelBounds, { + name: 'cell-view-cursor-' + viewId, viewId: viewId, fill: false, color: backgroundColor, @@ -5261,12 +5262,12 @@ L.CanvasTileLayer = L.Layer.extend({ this._printTwipsMessagesForReplay.save(msgType, textMsg, viewId); }, - _clearMsgReplayStore: function () { + _clearMsgReplayStore: function (notOtherMsg) { if (!this._printTwipsMessagesForReplay) { return; } - this._printTwipsMessagesForReplay.clear(); + this._printTwipsMessagesForReplay.clear(notOtherMsg); }, _replayPrintTwipsMsgs: function (differentSheet) { @@ -7494,16 +7495,18 @@ L.MessageStore = L.Class.extend({ this._othersMessages = othersMessages; }, - clear: function () { + clear: function (notOtherMsg) { var msgs = this._ownMessages; Object.keys(msgs).forEach(function (msgType) { msgs[msgType] = ''; }); - msgs = this._othersMessages; - Object.keys(msgs).forEach(function (msgType) { - msgs[msgType] = []; - }); + if (!notOtherMsg) { + msgs = this._othersMessages; + Object.keys(msgs).forEach(function (msgType) { + msgs[msgType] = []; + }); + } }, save: function (msgType, textMsg, viewId) { diff --git a/cypress_test/data/multiuser/calc/cell_cursor_overlay.ods b/cypress_test/data/multiuser/calc/cell_cursor_overlay.ods new file mode 100644 index 0000000000..dab7d7372b Binary files /dev/null and b/cypress_test/data/multiuser/calc/cell_cursor_overlay.ods differ diff --git a/cypress_test/integration_tests/multiuser/calc/sheet_operations_spec.js b/cypress_test/integration_tests/multiuser/calc/sheet_operations_spec.js index a8278b7a84..917e9e1a03 100644 --- a/cypress_test/integration_tests/multiuser/calc/sheet_operations_spec.js +++ b/cypress_test/integration_tests/multiuser/calc/sheet_operations_spec.js @@ -1,4 +1,4 @@ -/* global describe it cy beforeEach require afterEach */ +/* global describe it cy beforeEach require afterEach expect */ var helper = require('../../common/helper'); @@ -63,3 +63,74 @@ describe.skip(['tagmultiuser'], 'Multiuser sheet operations', function() { }); }); + +describe(['tagmultiuser'], 'Check overlays after tab switching/operations', function() { + const origTestFileName = 'cell_cursor_overlay.ods'; + let testFileName; + + beforeEach(function() { + testFileName = helper.beforeAll(origTestFileName, 'calc', undefined, true); + }); + + afterEach(function() { + helper.afterAll(testFileName, this.currentTest.state); + }); + + it('Check cell cursor overlay bounds after switching tab', function () { + cy.cSetActiveFrame('#iframe1'); + cy.cGet('#spreadsheet-tab1').click(); + cy.cGet('input#addressInput').should('have.prop', 'value', 'A14'); + + let cellA14Bounds = new helper.Bounds(); + helper.getOverlayItemBounds('#test-div-overlay-cell-cursor-border-0', cellA14Bounds); + + cy.cSetActiveFrame('#iframe2'); + // Check that cell cursor have the same bounds in both views + cy.cGet('#spreadsheet-tab1').click(); + cy.cGet('input#addressInput').should('have.prop', 'value', 'A14'); + helper.overlayItemHasBounds('#test-div-overlay-cell-cursor-border-0', cellA14Bounds); + }); + + it('Check cell view cursor overlay bounds after switching tab', function () { + cy.cSetActiveFrame('#iframe1'); + cy.cGet('#spreadsheet-tab1').click(); + + let cellA14Bounds = new helper.Bounds(); + helper.getOverlayItemBounds('#test-div-overlay-cell-cursor-border-0', cellA14Bounds); + + cy.cSetActiveFrame('#iframe2'); + cy.cGet('#spreadsheet-tab1').click(); + + // check that cell cursor and cell view cursor from first view have the same bounds + // since we don't know if view 0 has been loaded in frame1 or in frame2 we look for an element + // starting with 'test-div-overlay-cell-view-cursor' and ending with 'border-0'. + cy.cframe() + .find('[id^="test-div-overlay-cell-view-cursor"][id$="border-0"]') + .then(elements => { + expect(elements.length).to.be.equals(1); + const id = elements[0].id; + // cy.log('id: ' + id); + helper.overlayItemHasBounds('#' + id, cellA14Bounds); + }); + }); + + it('Check cell view cursor overlay bounds after inserting a new tab', function () { + cy.cSetActiveFrame('#iframe1'); + cy.cGet('input#addressInput').should('have.prop', 'value', 'D8'); + + cy.cSetActiveFrame('#iframe2'); + helper.typeIntoInputField('input#addressInput', 'F6'); + cy.cGet('input#addressInput').should('have.prop', 'value', 'F6'); + + cy.cSetActiveFrame('#iframe1'); + cy.cGet('#tb_spreadsheet-toolbar_item_insertsheet').click(); + + // check that there is no cell view cursor; + // in fact in the other view the new sheet has never been selected + // since we don't know if view 0 has been loaded in frame1 or in frame2 we test for both. + cy.cGet('#test-div-overlay-cell-view-cursor-0-border-0').should('not.exist'); + cy.cGet('#test-div-overlay-cell-view-cursor-1-border-0').should('not.exist'); + }); + +}); +