Skip to content

Commit 702537d

Browse files
devvaannshabose
authored andcommitted
feat: show tooltip when close button is hovered along with keyboard shortcut
1 parent c68c2d9 commit 702537d

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/extensionsIntegrated/TabBar/main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ define(function (require, exports, module) {
2828
const FileUtils = require("file/FileUtils");
2929
const CommandManager = require("command/CommandManager");
3030
const Commands = require("command/Commands");
31+
const KeyBindingManager = require("command/KeyBindingManager");
3132
const DocumentManager = require("document/DocumentManager");
3233
const WorkspaceManager = require("view/WorkspaceManager");
3334
const Menus = require("command/Menus");
@@ -515,6 +516,23 @@ define(function (require, exports, module) {
515516
}
516517
});
517518

519+
// add listener for tab close button to show the tooltip along with the keybinding
520+
$(document).on("mouseenter", ".phoenix-tab-bar .tab-close", function () {
521+
522+
// there can be more than 1 keybinding for 'Close' as one is default and other one is user-set
523+
// we need to get the user created keybinding...
524+
const closeBindings = KeyBindingManager.getKeyBindings(Commands.FILE_CLOSE);
525+
const closeShortcut = closeBindings.length > 0
526+
? KeyBindingManager.formatKeyDescriptor(closeBindings[closeBindings.length - 1].displayKey)
527+
: "";
528+
529+
const closeTabTooltip = closeShortcut
530+
? `${Strings.CLOSE_TAB_TOOLTIP} (${closeShortcut})`
531+
: Strings.CLOSE_TAB_TOOLTIP;
532+
533+
$(this).attr("title", closeTabTooltip);
534+
});
535+
518536
// open tab on mousedown event
519537
$(document).on("mousedown", ".phoenix-tab-bar .tab", function (event) {
520538
if ($(event.target).hasClass("fa-times") || $(event.target).closest(".tab-close").length) {

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ define({
501501
"CLOSE_TABS_TO_THE_LEFT": "Close Tabs to the Left",
502502
"CLOSE_ALL_TABS": "Close All Tabs",
503503
"CLOSE_SAVED_TABS": "Close Saved Tabs",
504+
"CLOSE_TAB_TOOLTIP": "Close Tab",
504505

505506
// CodeInspection: errors/warnings
506507
"ERRORS_NO_FILE": "No File Open",

0 commit comments

Comments
 (0)