diff --git a/web/src/components/SendDialog.js b/web/src/components/SendDialog.js
index 90824b3..ef80181 100644
--- a/web/src/components/SendDialog.js
+++ b/web/src/components/SendDialog.js
@@ -1,5 +1,5 @@
import * as React from 'react';
-import {useRef, useState} from 'react';
+import {useEffect, useRef, useState} from 'react';
import {NotificationItem} from "./Notifications";
import theme from "./theme";
import {Chip, FormControl, InputLabel, Link, Select, useMediaQuery} from "@mui/material";
@@ -24,6 +24,8 @@ import Icon from "./Icon";
import DialogFooter from "./DialogFooter";
import api from "../app/Api";
import Divider from "@mui/material/Divider";
+import EditIcon from '@mui/icons-material/Edit';
+import CheckIcon from '@mui/icons-material/Check';
const SendDialog = (props) => {
const [topicUrl, setTopicUrl] = useState(props.topicUrl);
@@ -326,43 +328,59 @@ const DialogIconButton = (props) => {
const AttachmentBox = (props) => {
const file = props.file;
- const maybeInfoText = formatBytes(file.size);
- const [editFilename, setEditFilename] = useState(false);
+ const invisibleFilenameRef = useRef();
+ const minFilenameWidth = 140;
+ const [filenameWidth, setFilenameWidth] = useState(minFilenameWidth);
+ const handleFilenameChange = (ev) => {
+ props.onChangeFilename(ev.target.value);
+ };
+ const determineFilenameWidth = () => {
+ const boundingRect = invisibleFilenameRef?.current?.getBoundingClientRect();
+ if (!boundingRect) {
+ return minFilenameWidth;
+ }
+ return (boundingRect.width >= minFilenameWidth) ? Math.round(boundingRect.width) : minFilenameWidth;
+ };
+ useEffect(() => {
+ setFilenameWidth(determineFilenameWidth() + 5);
+ }, [props.filename]);
return (
<>
-
+
+ {props.filename}
+
Attached file:
- props.onChangeFilename(ev.target.value)}
- fullWidth
- />
- {editFilename
- ?
- : {props.filename}
- }
- setEditFilename(true)}>
+
- {maybeInfoText}
+ {formatBytes(file.size)}
-
>
);
};