mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-11 16:38:50 +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
src
|
@ -273,6 +273,11 @@ code {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
details:not([open]) > summary ~ * {
|
||||||
|
/* HACK: allow JS know that this is invisible */
|
||||||
|
--invisible: 1;
|
||||||
|
}
|
||||||
|
|
||||||
[tabindex='-1'] {
|
[tabindex='-1'] {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,9 @@ function StatusPage() {
|
||||||
const activeStatusRect = activeStatus?.getBoundingClientRect();
|
const activeStatusRect = activeStatus?.getBoundingClientRect();
|
||||||
const allStatusLinks = Array.from(
|
const allStatusLinks = Array.from(
|
||||||
scrollableRef.current.querySelectorAll('.status-link, .status-focus'),
|
scrollableRef.current.querySelectorAll('.status-link, .status-focus'),
|
||||||
);
|
).filter((s) => {
|
||||||
|
return !getComputedStyle(s).getPropertyValue('--invisible');
|
||||||
|
});
|
||||||
console.log({ allStatusLinks });
|
console.log({ allStatusLinks });
|
||||||
if (
|
if (
|
||||||
activeStatus &&
|
activeStatus &&
|
||||||
|
@ -385,7 +387,9 @@ function StatusPage() {
|
||||||
const activeStatusRect = activeStatus?.getBoundingClientRect();
|
const activeStatusRect = activeStatus?.getBoundingClientRect();
|
||||||
const allStatusLinks = Array.from(
|
const allStatusLinks = Array.from(
|
||||||
scrollableRef.current.querySelectorAll('.status-link, .status-focus'),
|
scrollableRef.current.querySelectorAll('.status-link, .status-focus'),
|
||||||
);
|
).filter((s) => {
|
||||||
|
return !getComputedStyle(s).getPropertyValue('--invisible');
|
||||||
|
});
|
||||||
if (
|
if (
|
||||||
activeStatus &&
|
activeStatus &&
|
||||||
activeStatusRect.top < scrollableRef.current.clientHeight &&
|
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({
|
const { nearReachStart } = useScroll({
|
||||||
scrollableElement: scrollableRef.current,
|
scrollableElement: scrollableRef.current,
|
||||||
distanceFromStart: 0.2,
|
distanceFromStart: 0.2,
|
||||||
|
|
Loading…
Reference in a new issue