Files
eranos/src/hooks/useOpenPost.ts
T
Chad Curtis 984bada0a4 Add middle-click to open posts in new tab, fix word breaking in compose box
- Add useOpenPost hook to centralize left/middle-click navigation logic
- Apply middle-click (aux click) support to NoteCard, hot posts sidebar, and streams feed
- Fix ComposeBox textarea using break-all instead of break-words
2026-02-24 20:57:11 -06:00

21 lines
508 B
TypeScript

import { useNavigate } from 'react-router-dom';
/**
* Returns onClick and onAuxClick handlers for navigating to a post URL.
* - Left click: navigate in the same tab
* - Middle click: open in a new tab
*/
export function useOpenPost(path: string) {
const navigate = useNavigate();
const onClick = () => navigate(path);
const onAuxClick = (e: React.MouseEvent) => {
if (e.button !== 1) return;
e.preventDefault();
window.open(path, '_blank');
};
return { onClick, onAuxClick };
}