MM-62005 Change UrlView to always stay mounted (#3453)

* MM-62005 Change UrlView to always stay mounted

* Rename message for URL view and corresponding methods

* Change log level
This commit is contained in:
Harrison Healey
2025-07-04 09:37:13 -04:00
committed by GitHub
parent 8778edd238
commit 9d26b01ef5
6 changed files with 65 additions and 34 deletions

View File

@@ -1,22 +1,32 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useEffect} from 'react';
import React, {useEffect, useRef, useState} from 'react';
export default function UrlDescription(props: {url: string}) {
const urlRef = React.createRef<HTMLDivElement>();
export default function UrlDescription() {
const urlRef = useRef<HTMLDivElement>(null);
const [url, setUrl] = useState<string | undefined>();
useEffect(() => {
window.desktop.updateURLViewWidth(urlRef.current?.scrollWidth);
window.desktop.onSetURLForURLView((newUrl) => {
setUrl(newUrl);
});
}, []);
if (props.url) {
useEffect(() => {
if (url) {
window.desktop.updateURLViewWidth(urlRef.current?.scrollWidth);
}
}, [url]);
if (url) {
return (
<div
ref={urlRef}
className='HoveringURL HoveringURL-left'
>
<p>{props.url}</p>
<p>{url}</p>
</div>
);
}