Merge pull request #16570 from resilient-tech/fix-theme-switcher
fix: theme switcher shortcut issue
This commit is contained in:
commit
31d87176c1
3 changed files with 38 additions and 2 deletions
30
cypress/integration/theme_switcher_dialog.js
Normal file
30
cypress/integration/theme_switcher_dialog.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
context('Theme Switcher Shortcut', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
cy.visit('/app');
|
||||
});
|
||||
beforeEach(() => {
|
||||
cy.reload();
|
||||
});
|
||||
it('Check Toggle', () => {
|
||||
cy.open_theme_dialog('{ctrl+shift+g}');
|
||||
cy.get('.modal-backdrop').should('exist');
|
||||
cy.get('.theme-grid > div').first().click();
|
||||
cy.close_theme('{ctrl+shift+g}');
|
||||
cy.get('.modal-backdrop').should('not.exist');
|
||||
});
|
||||
it('Check Enter', () => {
|
||||
cy.open_theme_dialog('{ctrl+shift+g}');
|
||||
cy.get('.theme-grid > div').first().click();
|
||||
cy.close_theme('{enter}');
|
||||
cy.get('.modal-backdrop').should('not.exist');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Cypress.Commands.add('open_theme_dialog', (shortcut_keys) => {
|
||||
cy.get('body').type(shortcut_keys);
|
||||
});
|
||||
Cypress.Commands.add('close_theme', (shortcut_keys) => {
|
||||
cy.get('.modal-header').type(shortcut_keys);
|
||||
});
|
||||
|
|
@ -59,8 +59,12 @@ frappe.Application = class Application {
|
|||
shortcut: 'shift+ctrl+g',
|
||||
description: __('Switch Theme'),
|
||||
action: () => {
|
||||
frappe.theme_switcher = new frappe.ui.ThemeSwitcher();
|
||||
frappe.theme_switcher.show();
|
||||
if (frappe.theme_switcher && frappe.theme_switcher.dialog.is_visible) {
|
||||
frappe.theme_switcher.hide();
|
||||
} else {
|
||||
frappe.theme_switcher = new frappe.ui.ThemeSwitcher();
|
||||
frappe.theme_switcher.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ frappe.ui.ThemeSwitcher = class ThemeSwitcher {
|
|||
increment_by = 1;
|
||||
} else if (key === "left") {
|
||||
increment_by = -1;
|
||||
} else if (e.keyCode === 13) { // keycode 13 is for 'enter'
|
||||
this.hide();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue