Add 'x' for expanding content warning

This commit is contained in:
Lim Chee Aun 2023-12-20 16:42:36 +08:00
parent 9983c8086c
commit bee32cc781
2 changed files with 22 additions and 1 deletions

View file

@ -94,7 +94,13 @@ export default memo(function KeyboardShortcutsHelp() {
),
},
{
action: 'Toggle expanded/collapsed thread',
action: (
<>
Expand content warning or
<br />
toggle expanded/collapsed thread
</>
),
keys: <kbd>x</kbd>,
},
{

View file

@ -1021,6 +1021,20 @@ function Status({
enabled: hotkeysEnabled && canBoost,
},
);
const xRef = useHotkeys('x', (e) => {
const activeStatus = document.activeElement.closest(
'.status-link, .status-focus',
);
if (activeStatus) {
const spoilerButton = activeStatus.querySelector(
'button.spoiler:not(.spoiling)',
);
if (spoilerButton) {
e.stopPropagation();
spoilerButton.click();
}
}
});
const displayedMediaAttachments = mediaAttachments.slice(
0,
@ -1169,6 +1183,7 @@ function Status({
fRef.current = nodeRef;
dRef.current = nodeRef;
bRef.current = nodeRef;
xRef.current = nodeRef;
}}
tabindex="-1"
class={`status ${