mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Fix j/k shortcuts to work with collapsed comments
Use x key to expand/collapse comments
This commit is contained in:
parent
7d94c53e2e
commit
6647b6cc28
2 changed files with 25 additions and 2 deletions
|
@ -273,6 +273,11 @@ code {
|
|||
}
|
||||
}
|
||||
|
||||
details:not([open]) > summary ~ * {
|
||||
/* HACK: allow JS know that this is invisible */
|
||||
--invisible: 1;
|
||||
}
|
||||
|
||||
[tabindex='-1'] {
|
||||
outline: 0;
|
||||
}
|
||||
|
|
|
@ -352,7 +352,9 @@ function StatusPage() {
|
|||
const activeStatusRect = activeStatus?.getBoundingClientRect();
|
||||
const allStatusLinks = Array.from(
|
||||
scrollableRef.current.querySelectorAll('.status-link, .status-focus'),
|
||||
);
|
||||
).filter((s) => {
|
||||
return !getComputedStyle(s).getPropertyValue('--invisible');
|
||||
});
|
||||
console.log({ allStatusLinks });
|
||||
if (
|
||||
activeStatus &&
|
||||
|
@ -385,7 +387,9 @@ function StatusPage() {
|
|||
const activeStatusRect = activeStatus?.getBoundingClientRect();
|
||||
const allStatusLinks = Array.from(
|
||||
scrollableRef.current.querySelectorAll('.status-link, .status-focus'),
|
||||
);
|
||||
).filter((s) => {
|
||||
return !getComputedStyle(s).getPropertyValue('--invisible');
|
||||
});
|
||||
if (
|
||||
activeStatus &&
|
||||
activeStatusRect.top < scrollableRef.current.clientHeight &&
|
||||
|
@ -410,6 +414,20 @@ function StatusPage() {
|
|||
}
|
||||
});
|
||||
|
||||
// NOTE: I'm not sure if 'x' is the best shortcut for this, might change it later
|
||||
// IDEA: x is for expand
|
||||
useHotkeys('x', () => {
|
||||
const activeStatus = document.activeElement.closest(
|
||||
'.status-link, .status-focus',
|
||||
);
|
||||
if (activeStatus) {
|
||||
const details = activeStatus.nextElementSibling;
|
||||
if (details && details.tagName.toLowerCase() === 'details') {
|
||||
details.open = !details.open;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const { nearReachStart } = useScroll({
|
||||
scrollableElement: scrollableRef.current,
|
||||
distanceFromStart: 0.2,
|
||||
|
|
Loading…
Reference in a new issue