1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2024-11-23 17:42:46 +01:00
TweetDuck/resources/Content/tweetdeck/focus_composer_after_alt_tab.js

33 lines
821 B
JavaScript

import { $ } from "../api/jquery.js";
import { replaceFunction } from "../api/patch.js";
import { onAppReady } from "../api/ready.js";
import { prioritizeNewestEvent } from "./globals/prioritize_newest_event.js";
/**
* Refocuses composer input after Alt+Tab.
*/
export default function() {
onAppReady(function fixDockedComposerRefocus() {
$(document).on("tduckOldComposerActive", function() {
const ele = document.querySelector(".js-docked-compose .js-compose-text");
let cancelBlur = false;
$(ele).on("blur", function() {
cancelBlur = true;
setTimeout(function() {
cancelBlur = false;
}, 0);
});
prioritizeNewestEvent(ele, "blur");
replaceFunction(ele, "blur", function(func, args) {
if (!cancelBlur) {
func.apply(this, args);
}
});
});
});
};