This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree 1 file changed +18
-2
lines changed
src/components/views/elements
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
31
31
import AccessibleButton from "./AccessibleButton" ;
32
32
import TooltipTarget from "./TooltipTarget" ;
33
33
import { Linkify , topicToHtml } from "../../../HtmlUtils" ;
34
+ import { tryTransformPermalinkToLocalHref } from "../../../utils/permalinks/Permalinks" ;
34
35
35
36
interface IProps extends React . HTMLProps < HTMLDivElement > {
36
37
room : Room ;
@@ -46,12 +47,27 @@ export default function RoomTopic({ room, ...props }: IProps): JSX.Element {
46
47
const onClick = useCallback (
47
48
( e : React . MouseEvent < HTMLDivElement > ) => {
48
49
props . onClick ?.( e ) ;
50
+
49
51
const target = e . target as HTMLElement ;
50
- if ( target . tagName . toUpperCase ( ) === "A" ) {
52
+
53
+ if ( target . tagName . toUpperCase ( ) !== "A" ) {
54
+ dis . fire ( Action . ShowRoomTopic ) ;
55
+ return ;
56
+ }
57
+
58
+ const anchor : HTMLLinkElement | null = e . target as HTMLLinkElement ;
59
+
60
+ if ( ! anchor ) {
51
61
return ;
52
62
}
53
63
54
- dis . fire ( Action . ShowRoomTopic ) ;
64
+ const localHref = tryTransformPermalinkToLocalHref ( anchor . href ) ;
65
+
66
+ if ( localHref !== anchor . href ) {
67
+ // it could be converted to a localHref -> therefore handle locally
68
+ e . preventDefault ( ) ;
69
+ window . location . hash = localHref ;
70
+ }
55
71
} ,
56
72
[ props ] ,
57
73
) ;
You can’t perform that action at this time.
0 commit comments