984bada0a4
- 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
21 lines
508 B
TypeScript
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 };
|
|
}
|