redone fix of focus sticking to tab after click (#4087)
- revert debcb9944d
since it breaks
drag-drop reordering of tabs
- when reader is being refocused by contextPane, add a small delay
so that the focus settles on the tab before focusing the reader
- also explicitly refocus the reader tab after drag, since then focus
also lands on the tab and finds itself outside of the reader
This commit is contained in:
parent
59b1d75b98
commit
ffef57eed1
3 changed files with 19 additions and 3 deletions
|
@ -128,8 +128,6 @@ const TabBar = forwardRef(function (props, ref) {
|
|||
}
|
||||
props.onTabSelect(id);
|
||||
event.stopPropagation();
|
||||
// Prevents focus from sticking to the actual tab on windows
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function handleTabClick(event, id) {
|
||||
|
@ -162,6 +160,7 @@ const TabBar = forwardRef(function (props, ref) {
|
|||
|
||||
function handleDragEnd() {
|
||||
setDragging(false);
|
||||
props.refocusReader();
|
||||
}
|
||||
|
||||
function handleTabBarDragOver(event) {
|
||||
|
|
|
@ -203,7 +203,11 @@
|
|||
|| !document.activeElement.closest('.context-node iframe[id="editor-view"]'))) {
|
||||
if (!Zotero_Tabs.focusOptions?.keepTabFocused) {
|
||||
// Do not move focus to the reader during keyboard navigation
|
||||
reader.focus();
|
||||
setTimeout(() => {
|
||||
// Timeout to make sure focus does not stick to the tab
|
||||
// after click on windows
|
||||
reader.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ var Zotero_Tabs = new function () {
|
|||
onTabMove={this.move.bind(this)}
|
||||
onTabClose={this.close.bind(this)}
|
||||
onContextMenu={this._openMenu.bind(this)}
|
||||
refocusReader={this.refocusReader.bind(this)}
|
||||
/>,
|
||||
document.getElementById('tab-bar-container'),
|
||||
() => {
|
||||
|
@ -569,6 +570,18 @@ var Zotero_Tabs = new function () {
|
|||
this.select(this._tabs[this._tabs.length - 1].id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return focus into the reader of the selected tab.
|
||||
* Required to move focus from the tab into the reader after drag.
|
||||
*/
|
||||
this.refocusReader = function () {
|
||||
var reader = Zotero.Reader.getByTabID(this._selectedID);
|
||||
if (!reader) return;
|
||||
setTimeout(() => {
|
||||
reader.focus();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves focus to a tab in the specified direction.
|
||||
* @param {String} direction. "first", "last", "left", "right", or "current"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue