Skip to content

Commit

Permalink
feat(plugins): remove jQuery from CellMenu & ContextMenu plugins (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored May 4, 2023
1 parent 9ea0d9a commit c4671be
Show file tree
Hide file tree
Showing 7 changed files with 474 additions and 398 deletions.
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

0 comments on commit c4671be

Please sign in to comment.