diff --git a/lib/web/mage/adminhtml/grid.js b/lib/web/mage/adminhtml/grid.js
index c9af869d79161..5f7a709f04fea 100644
--- a/lib/web/mage/adminhtml/grid.js
+++ b/lib/web/mage/adminhtml/grid.js
@@ -530,13 +530,20 @@ define([
/**
* @param {Object} event
+ * @param {*} lastId
*/
- inputPage: function (event) {
+ inputPage: function (event, lastId) {
var element = Event.element(event),
- keyCode = event.keyCode || event.which;
+ keyCode = event.keyCode || event.which,
+ enteredValue = parseInt(element.value, 10),
+ pageId = parseInt(lastId, 10);
if (keyCode == Event.KEY_RETURN) { //eslint-disable-line eqeqeq
- this.setPage(element.value);
+ if (enteredValue > pageId) {
+ this.setPage(pageId);
+ } else {
+ this.setPage(enteredValue);
+ }
}
/*if(keyCode>47 && keyCode<58){