Skip to content

Commit dae27f6

Browse files
gokaysatireszkadev
authored andcommitted
Impress: Handle CTRL+C and CTRL+V differently when slide sorter is focused.
Issue: When user clicks on a slide and then performs "CTRL+C", document should send an ".uno:CopySlide" command to the core side. But after clicking on a slide, 2 callbacks are fired: "onfocus" and "onblur". Seems that "onblur" fired after the onfocus callback, interestingly. This causes slide sorter to lose focus (partsFocused = false). Thus, an ".uno:Copy" command is sent instead of ".uno:CopySlide" command. Fix: onblur event doesn't seem to be reliable for this operation. It is better to handle the copy and paste events in Map.Keyboard code. That part already handles other key combinations of slide sorter. Also, after declaring that slide sorter lost focus (Map.Keyboard -> partsFocused = false), we need to set the focus to the document. Adding that map.focus() call also ensure better user experience. Also adds a test for slide sorter focus. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I70a4320a44613f7b83c52393bbcb65e904ce55f4
1 parent 2c963c2 commit dae27f6

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

browser/src/control/Control.PartsPreview.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ window.L.Control.PartsPreview = window.L.Control.extend({
235235
that.partsFocused = true;
236236
};
237237

238-
img.onblur = function () {
239-
that._map._clip.clearSelection();
240-
that.partsFocused = false;
241-
};
242-
243238
var that = this;
244239
window.L.DomEvent.on(frame, 'contextmenu', function(e) {
245240
var isMasterView = this._map['stateChangeHandler'].getItemValue('.uno:SlideMasterPage');

browser/src/map/handler/Map.Keyboard.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ window.L.Map.Keyboard = window.L.Handler.extend({
415415
return;
416416
}
417417
else if (this._map._docLayer && (this._map._docLayer._docType === 'presentation' || this._map._docLayer._docType === 'drawing') && this._map._docLayer._preview.partsFocused === true) {
418-
419418
if (!this.modifier && (ev.keyCode === this.keyCodes.DOWN || ev.keyCode === this.keyCodes.UP ||
420419
ev.keyCode === this.keyCodes.RIGHT || ev.keyCode === this.keyCodes.LEFT ||
421420
ev.keyCode === this.keyCodes.PAGEDOWN || ev.keyCode === this.keyCodes.PAGEUP ||
@@ -440,20 +439,19 @@ window.L.Map.Keyboard = window.L.Handler.extend({
440439
this._map.deletePage(this._map._docLayer._selectedPart);
441440
}
442441
ev.preventDefault();
443-
return;
444442
}
445-
else if (ev.ctrlKey) {
446-
if (!ev.altKey && ev.keyCode === this.keyCodes.HOME)
447-
this._map.setPart(0);
448-
else if (!ev.altKey && ev.keyCode === this.keyCodes.END)
449-
this._map.setPart(this._map._docLayer._parts - 1);
450-
else {
451-
this._handleCtrlCommand(ev);
452-
return;
453-
}
443+
else if (ev.ctrlKey && !ev.altKey && ev.keyCode === this.keyCodes.HOME)
444+
app.map.setPart(0);
445+
else if (ev.ctrlKey && !ev.altKey && ev.keyCode === this.keyCodes.END)
446+
app.map.setPart(app.map._docLayer._parts - 1);
447+
else if (ev.ctrlKey && !ev.altKey && this.keyCodes.C.includes(ev.keyCode)) {
448+
app.map._clip.clearSelection();
449+
app.map._clip.setTextSelectionType('slide');
454450
}
455-
else {
451+
else if (!ev.ctrlKey) {
456452
this._map._docLayer._preview.partsFocused = false;
453+
app.map._clip.clearSelection();
454+
app.map.focus();
457455
}
458456
}
459457
},

cypress_test/integration_tests/desktop/impress/slide_operations_spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Slide operations', functio
4040

4141
});
4242

43+
it('Check slide sorter focus', function() {
44+
cy.cGet('#insertpage-button').click();
45+
cy.wait(100);
46+
47+
// Set the focus to slide sorter.
48+
cy.cGet('#preview-frame-part-0').click();
49+
cy.cGet('#preview-frame-part-1').click();
50+
51+
// Slide sorter should keep focus while user clicks on different slides.
52+
cy.window().then(win => {
53+
const app = win['0'].app;
54+
cy.expect(app.map._docLayer._preview.partsFocused).to.be.equal(true);
55+
});
56+
});
57+
4358
it('Duplicate slide', function() {
4459
// Also check if comments are getting duplicated
4560
desktopHelper.closeNavigatorSidebar();

0 commit comments

Comments
 (0)