leaflet: don't allow focus stealing
This improves typing in the formula-bar. Change-Id: I14359b5b4e842b68b1807d286e1831b3805bb4ea Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91019 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
This commit is contained in:
parent
41cd5a5624
commit
e9157a886f
4 changed files with 51 additions and 16 deletions
|
@ -80,6 +80,10 @@ function assertHaveKeyboardInput() {
|
|||
function assertCursorAndFocus() {
|
||||
cy.log('Verifying Cursor and Focus.');
|
||||
|
||||
// Active element must be the textarea named clipboard.
|
||||
cy.document().its('activeElement.className')
|
||||
.should('be.eq', 'clipboard');
|
||||
|
||||
// In edit mode, we should have the blinking cursor.
|
||||
cy.get('.leaflet-cursor.blinking-cursor')
|
||||
.should('exist');
|
||||
|
@ -122,7 +126,7 @@ function clearAllText() {
|
|||
// clipboard (which Cypress doesn't support).
|
||||
// Takes a closure f that takes the text
|
||||
// string as argument. Use as follows:
|
||||
// helper.getTextForClipboard((htmlText, plainText) => {
|
||||
// helper.getTextForClipboard((plainText) => {
|
||||
// expect(plainText, 'Selection Text').to.equal(testText);
|
||||
// });
|
||||
function getTextForClipboard(f) {
|
||||
|
|
|
@ -70,4 +70,35 @@ describe('Calc focus tests', function() {
|
|||
cy.document().its('activeElement.className')
|
||||
.should('be.eq', 'clipboard');
|
||||
});
|
||||
|
||||
it('Formula-bar focus', function() {
|
||||
// Click on edit button
|
||||
helper.enableEditingMobile();
|
||||
|
||||
// Body has the focus -> can't type in the document
|
||||
cy.document().its('activeElement.tagName')
|
||||
.should('be.eq', 'BODY');
|
||||
|
||||
helper.assertNoKeyboardInput();
|
||||
|
||||
// One tap on a cell -> no document focus
|
||||
calcHelper.clickOnFirstCell();
|
||||
|
||||
cy.get('.leaflet-marker-icon')
|
||||
.should('be.visible');
|
||||
|
||||
// No focus
|
||||
cy.document().its('activeElement.tagName')
|
||||
.should('be.eq', 'BODY');
|
||||
|
||||
// Click in the formula-bar.
|
||||
cy.get('.inputbar_container')
|
||||
.click();
|
||||
|
||||
helper.assertCursorAndFocus();
|
||||
|
||||
// Type some text.
|
||||
cy.get('textarea.clipboard')
|
||||
.type('blah');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1171,7 +1171,7 @@ L.TileLayer = L.GridLayer.extend({
|
|||
this._showURLPopUp(cursorPos, obj.hyperlink.link);
|
||||
}
|
||||
|
||||
if (!this._map.editorHasFocus() && (modifierViewId === this._viewId) && (this._map._permission === 'edit')) {
|
||||
if (!this._map.editorHasFocus() && this._map._isCursorVisible && (modifierViewId === this._viewId) && (this._map._permission === 'edit')) {
|
||||
// Regain cursor if we had been out of focus and now have input.
|
||||
// (only if it is our own cursor and the input is actually not
|
||||
// going into a dialog)
|
||||
|
@ -2188,20 +2188,18 @@ L.TileLayer = L.GridLayer.extend({
|
|||
|
||||
this._updateCursorPos();
|
||||
|
||||
// Update the cursor/keyboard only when the document has focus.
|
||||
if (this._map.editorHasFocus()) {
|
||||
this._map._textInput.showCursor();
|
||||
this._map._textInput.showCursor();
|
||||
|
||||
// Don't show the keyboard when the Wizard is visible.
|
||||
if (!window.mobileWizard) {
|
||||
// If the user is editing, show the keyboard, but don't change
|
||||
// anything if nothing is changed.
|
||||
this._map.focus(true);
|
||||
}
|
||||
// Don't show the keyboard when the Wizard is visible.
|
||||
if (!window.mobileWizard) {
|
||||
// If the user is editing, show the keyboard, but don't change
|
||||
// anything if nothing is changed.
|
||||
this._map.focus(true);
|
||||
}
|
||||
} else {
|
||||
this._map._textInput.hideCursor();
|
||||
this._map.focus(false);
|
||||
if (this._map.editorHasFocus()) // Allow input if a dialog has the focus.
|
||||
this._map.focus(false);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1408,12 +1408,14 @@ L.Map = L.Evented.extend({
|
|||
this._activeDialog = dialog;
|
||||
this._isSearching = false;
|
||||
|
||||
var doclayer = this._docLayer;
|
||||
if (doclayer)
|
||||
if (this.editorHasFocus()) {
|
||||
// The document has the focus.
|
||||
var doclayer = this._docLayer;
|
||||
doclayer._updateCursorAndOverlay();
|
||||
|
||||
if (acceptInput !== undefined)
|
||||
} else if (acceptInput !== undefined) {
|
||||
// A dialog has the focus.
|
||||
this.focus(acceptInput);
|
||||
}
|
||||
},
|
||||
|
||||
// Our browser tab lost focus.
|
||||
|
|
Loading…
Reference in a new issue