Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 0cee7d4

Browse files
niteskumboopeshmahendran
authored andcommitted
Fixed ExtractToVariable Menu Close Issue due to scrolling (#14492)
* Fixed ExtractToVariable Menu Close Issue due to scrolling * Addressed Review Comments * Addessed review comments * Addressed Review Comments * Addressed Review Comments
1 parent afcbff0 commit 0cee7d4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,19 @@ define(function(require, exports, module) {
303303
inlineMenu = new InlineMenu(session.editor, Strings.EXTRACTTO_VARIABLE_SELECT_EXPRESSION);
304304

305305
inlineMenu.onHover(function (expnId) {
306+
// Remove the scroll Handlers If already Attached.
307+
editor.off("scroll.inlinemenu");
308+
// Add a scroll handler If Selection Range is not View.
309+
// This is Added for a Bug, where Menu used not to open for the first Time
310+
if(!editor.isLineVisible(editor.posFromIndex(expns[expnId].end).line)) {
311+
editor.on("scroll.inlinemenu", function() {
312+
// Remove the Handlers so that If scroll event is triggerd again by any other operation
313+
// Menu should not be reopened.
314+
// Menu Should be reopened only if Scroll event is triggered by onHover.
315+
editor.off("scroll.inlinemenu");
316+
inlineMenu.openRemovedMenu();
317+
});
318+
}
306319
editor.setSelection(editor.posFromIndex(expns[expnId].start), editor.posFromIndex(expns[expnId].end));
307320
});
308321

src/widgets/InlineMenu.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,19 @@ define(function (require, exports, module) {
413413
}
414414
};
415415

416+
/**
417+
* Displays the last menu which was closed due to Scrolling
418+
*/
419+
InlineMenu.prototype.openRemovedMenu = function () {
420+
if (this.opened === true) {
421+
if (this.$menu && !this.$menu.hasClass("open")) {
422+
var menuPos = this._calcMenuLocation();
423+
this.$menu.addClass("open")
424+
.css({"left": menuPos.left, "top": menuPos.top, "width": menuPos.width + "px"});
425+
}
426+
}
427+
};
428+
416429
/**
417430
* Closes the menu
418431
*/

0 commit comments

Comments
 (0)