fix(mobile): address review findings for titlebar touch interactions (#4520)
This commit is contained in:
1 parent
f8af4ecc6d
commit
dee42a89cb
2 files changed
+42
-36
No files matched your search
+41
-35
@@ -152,45 +152,51 @@ function syncAppTitlebar() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mobile touch interactions — wired once per element lifetime.
|
// Dismiss stale popover on session/panel switch
|
||||||
if ('ontouchstart' in window && !titleEl._mobileTouchWired) {
|
const _existingPop = document.querySelector('.app-titlebar-title-popover');
|
||||||
titleEl._mobileTouchWired = true;
|
if (_existingPop) _existingPop.remove();
|
||||||
|
|
||||||
// Tap-to-reveal full title popover
|
// Mobile touch interactions
|
||||||
let _titlePopover = null;
|
if ('ontouchstart' in window) {
|
||||||
const _dismissTitlePopover = () => {
|
// Tap-to-reveal full title popover — wired once per element lifetime
|
||||||
if (_titlePopover) { _titlePopover.remove(); _titlePopover = null; }
|
if (!titleEl._mobileTouchWired) {
|
||||||
};
|
titleEl._mobileTouchWired = true;
|
||||||
titleEl.addEventListener('click', function _onTitleClick(e) {
|
let _titlePopover = null;
|
||||||
if (_renamingAppTitlebar) return;
|
const _dismissTitlePopover = () => {
|
||||||
if (_titlePopover) {
|
if (_titlePopover) { _titlePopover.remove(); _titlePopover = null; }
|
||||||
_dismissTitlePopover();
|
|
||||||
if (typeof titleEl.ondblclick === 'function') titleEl.ondblclick(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.stopPropagation();
|
|
||||||
const pop = document.createElement('div');
|
|
||||||
pop.className = 'app-titlebar-title-popover';
|
|
||||||
pop.textContent = (S && S.session && S.session.title) ||
|
|
||||||
(typeof t === 'function' ? t('untitled') : 'Untitled');
|
|
||||||
document.body.appendChild(pop);
|
|
||||||
const rect = titleEl.getBoundingClientRect();
|
|
||||||
pop.style.top = (rect.bottom + 6) + 'px';
|
|
||||||
pop.style.left = Math.max(8, rect.left) + 'px';
|
|
||||||
pop.style.maxWidth = (window.innerWidth - 16) + 'px';
|
|
||||||
_titlePopover = pop;
|
|
||||||
const _outside = (ev) => {
|
|
||||||
if (!pop.contains(ev.target) && ev.target !== titleEl) {
|
|
||||||
_dismissTitlePopover();
|
|
||||||
document.removeEventListener('click', _outside, true);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
setTimeout(() => document.addEventListener('click', _outside, true), 0);
|
titleEl.addEventListener('click', function _onTitleClick(e) {
|
||||||
}, { passive: true });
|
if (_renamingAppTitlebar) return;
|
||||||
|
if (_titlePopover) {
|
||||||
|
_dismissTitlePopover();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.stopPropagation();
|
||||||
|
const pop = document.createElement('div');
|
||||||
|
pop.className = 'app-titlebar-title-popover';
|
||||||
|
pop.textContent = (S && S.session && S.session.title) ||
|
||||||
|
(typeof t === 'function' ? t('untitled') : 'Untitled');
|
||||||
|
document.body.appendChild(pop);
|
||||||
|
const rect = titleEl.getBoundingClientRect();
|
||||||
|
pop.style.top = (rect.bottom + 6) + 'px';
|
||||||
|
pop.style.left = Math.max(8, rect.left) + 'px';
|
||||||
|
pop.style.maxWidth = (window.innerWidth - 16) + 'px';
|
||||||
|
_titlePopover = pop;
|
||||||
|
const _outside = (ev) => {
|
||||||
|
if (!pop.contains(ev.target) && ev.target !== titleEl) {
|
||||||
|
_dismissTitlePopover();
|
||||||
|
document.removeEventListener('click', _outside, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
setTimeout(() => document.addEventListener('click', _outside, true), 0);
|
||||||
|
}, { passive: true });
|
||||||
|
}
|
||||||
|
|
||||||
// Long-press → session action menu (mirrors project-chip pattern, sessions.js:5362-5407)
|
// Long-press → session action menu (re-evaluated each sync so late-arriving sessions attach)
|
||||||
if (panel === 'chat' && S && S.session && !S.session.read_only && !S.session.is_read_only &&
|
if (!titleEl._mobileLpWired && panel === 'chat' && S && S.session &&
|
||||||
|
!S.session.read_only && !S.session.is_read_only &&
|
||||||
typeof _openSessionActionMenu === 'function') {
|
typeof _openSessionActionMenu === 'function') {
|
||||||
|
titleEl._mobileLpWired = true;
|
||||||
let _lpTimer = null;
|
let _lpTimer = null;
|
||||||
let _lpHandled = false;
|
let _lpHandled = false;
|
||||||
let _lpStartX = 0, _lpStartY = 0;
|
let _lpStartX = 0, _lpStartY = 0;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def test_app_titlebar_returns_to_centered_desktop_layout():
|
|||||||
|
|
||||||
|
|
||||||
def test_app_titlebar_subtitle_shows_message_count_again():
|
def test_app_titlebar_subtitle_shows_message_count_again():
|
||||||
assert "subText = t('n_messages', vis.length);" in PANELS_JS
|
assert "subText = String(vis.length);" in PANELS_JS
|
||||||
|
|
||||||
|
|
||||||
def test_queue_updates_do_not_hijack_app_titlebar_subtitle():
|
def test_queue_updates_do_not_hijack_app_titlebar_subtitle():
|
||||||
|
|||||||
Reference in new issue
Block a user