diff --git a/core/modules/shortcut/shortcut.admin.js b/core/modules/shortcut/shortcut.admin.js
index 9a730fa..bdf9549 100644
--- a/core/modules/shortcut/shortcut.admin.js
+++ b/core/modules/shortcut/shortcut.admin.js
@@ -41,15 +41,20 @@ Drupal.behaviors.shortcutDrag = {
         var total = slots - count;
         if (total == -1) {
           var disabled = $(table).find('tr.shortcut-status-disabled');
-          disabled.after(disabled.prevAll().filter(':not(.shortcut-slot-empty)').get(0));
-          if ($(swappedRow).hasClass('draggable')) {
+          // To maintain the shortcut links limit, need to move last element
+          // from enabled section to disabled section.
+          // changedRow will point to last row in Enabled section which needs to move
+          // to disabled section.
+          changedRow = disabled.prevAll().filter(':not(.shortcut-slot-empty)').get(0);
+          disabled.after(changedRow);
+          if ($(changedRow).hasClass('draggable')) {
             // The dropped element will automatically be marked as changed by
             // the tableDrag system. However, the row that swapped with it
             // has moved to the "disabled" section, so we need to force its
             // status to be disabled and mark it also as changed.
-            swappedRowObject = new tableDrag.row(swappedRow, 'mouse', self.indentEnabled, self.maxDepth, true);
-            swappedRowObject.markChanged();
-            rowStatusChange(swappedRowObject);
+            changedRowObject = new tableDrag.row(changedRow, 'mouse', self.indentEnabled, self.maxDepth, true);
+            changedRowObject.markChanged();
+            rowStatusChange(changedRowObject);
           }
         }
         else if (total != visibleLength) {
