Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins): remove jQuery from CellMenu & ContextMenu plugins #753

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"env": {
"browser": true,
"es2015": true,
"es6": true,
"node": true
},
"globals": {
Expand Down
2 changes: 1 addition & 1 deletion controls/slick.columnpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
}

function handleBodyMouseDown(e) {
if ((_menuElm !== e.target && !_menuElm.contains(e.target)) || e.target.className === 'close') {
if ((_menuElm !== e.target && !(_menuElm && _menuElm.contains(e.target))) || e.target.className === 'close') {
_menuElm.setAttribute('aria-expanded', 'false');
_menuElm.style.display = 'none';
}
Expand Down
15 changes: 12 additions & 3 deletions cypress/integration/example-plugin-contextmenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ describe('Example - Context Menu & Cell Menu', () => {
.find('.slick-row .slick-cell:nth(1)')
.rightclick();

cy.get('.slick-context-menu-command-list')
.should('exist');

cy.get('.slick-context-menu-option-list')
.should('not.exist');

cy.window().then((win) => {
expect(win.console.log).to.have.callCount(2);
expect(win.console.log).to.be.calledWith('Before the global Context Menu is shown');
Expand Down Expand Up @@ -118,13 +124,16 @@ describe('Example - Context Menu & Cell Menu', () => {
.find('.slick-row .slick-cell:nth(5)')
.rightclick();

cy.get('.slick-context-menu-command-list')
.should('not.exist');

cy.get('.slick-context-menu-option-list')
.should('exist');

cy.get('.slick-context-menu .slick-context-menu-option-list')
.contains('High')
.click();

cy.get('.slick-context-menu-command-list')
.should('not.exist');

cy.get('#myGrid')
.find('.slick-row .slick-cell:nth(7)')
.contains('Action')
Expand Down
17 changes: 8 additions & 9 deletions examples/example-plugin-contextmenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ <h2>View Source:</h2>
</tr>
</table>

<script src="../lib/firebugx.js"></script>

<script src="../lib/jquery-3.1.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>

<script src="../slick.core.js"></script>
Expand Down Expand Up @@ -209,10 +206,12 @@ <h2>View Source:</h2>
window.clipboardData.setData("Text", textToCopy);
} else {
var range = document.createRange();
var tmpElem = $('<div>')
.css({ position: "absolute", left: "-1000px", top: "-1000px" })
.text(textToCopy);
$("body").append(tmpElem);
var tmpElem = document.createElement('div');
tmpElem.style.position = 'absolute';
tmpElem.style.left = '-1000px';
tmpElem.style.top = '-1000px';
tmpElem.textContent = textToCopy;
document.body.appendChild(tmpElem);
range.selectNodeContents(tmpElem.get(0));
var selection = window.getSelection();
selection.removeAllRanges();
Expand Down Expand Up @@ -432,7 +431,7 @@ <h2>View Source:</h2>
]
};

$(function () {
(function () {
dataView = new Slick.Data.DataView();
grid = new Slick.Grid("#myGrid", dataView, columns, gridOptions);
cellMenuPlugin = new Slick.Plugins.CellMenu({ hideMenuOnScroll: true });
Expand Down Expand Up @@ -534,7 +533,7 @@ <h2>View Source:</h2>
grid.updateRow(args.row);
}
});
});
})();

</script>
</body>
Expand Down
Loading