mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
fix(Map): Fixed pasting into Name, Custom Label and Description
This commit is contained in:
@@ -25,29 +25,14 @@ export const SystemSettingsDialog = ({ systemId, visible, setVisible }: SystemSe
|
|||||||
|
|
||||||
const isTempSystemNameEnabled = useMapGetOption('show_temp_system_name') === 'true';
|
const isTempSystemNameEnabled = useMapGetOption('show_temp_system_name') === 'true';
|
||||||
|
|
||||||
|
|
||||||
const system = getSystemById(systems, systemId);
|
const system = getSystemById(systems, systemId);
|
||||||
|
|
||||||
|
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
const [label, setLabel] = useState('');
|
const [label, setLabel] = useState('');
|
||||||
const [temporaryName, setTemporaryName] = useState('')
|
const [temporaryName, setTemporaryName] = useState('');
|
||||||
const [description, setDescription] = useState('');
|
const [description, setDescription] = useState('');
|
||||||
const inputRef = useRef<HTMLInputElement>();
|
const inputRef = useRef<HTMLInputElement>();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!system) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const labels = new LabelsManager(system.labels || '');
|
|
||||||
|
|
||||||
setName(system.name || '');
|
|
||||||
setLabel(labels.customLabel);
|
|
||||||
setTemporaryName(system.temporary_name || '');
|
|
||||||
setDescription(system.description || '');
|
|
||||||
}, [system]);
|
|
||||||
|
|
||||||
const ref = useRef({ name, description, temporaryName, label, outCommand, systemId, system });
|
const ref = useRef({ name, description, temporaryName, label, outCommand, systemId, system });
|
||||||
ref.current = { name, description, label, temporaryName, outCommand, systemId, system };
|
ref.current = { name, description, label, temporaryName, outCommand, systemId, system };
|
||||||
|
|
||||||
@@ -108,6 +93,21 @@ export const SystemSettingsDialog = ({ systemId, visible, setVisible }: SystemSe
|
|||||||
e.target.value = e.target.value.toUpperCase().replace(/[^A-Z0-9\-[\](){}]/g, '');
|
e.target.value = e.target.value.toUpperCase().replace(/[^A-Z0-9\-[\](){}]/g, '');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Attention: this effect should be call only on mount.
|
||||||
|
useEffect(() => {
|
||||||
|
const { system } = ref.current;
|
||||||
|
if (!system) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const labels = new LabelsManager(system.labels || '');
|
||||||
|
|
||||||
|
setName(system.name || '');
|
||||||
|
setLabel(labels.customLabel);
|
||||||
|
setTemporaryName(system.temporary_name || '');
|
||||||
|
setDescription(system.description || '');
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
header="System settings"
|
header="System settings"
|
||||||
@@ -182,7 +182,7 @@ export const SystemSettingsDialog = ({ systemId, visible, setVisible }: SystemSe
|
|||||||
</IconField>
|
</IconField>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isTempSystemNameEnabled &&
|
{isTempSystemNameEnabled && (
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<label htmlFor="username">Temporary Name</label>
|
<label htmlFor="username">Temporary Name</label>
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ export const SystemSettingsDialog = ({ systemId, visible, setVisible }: SystemSe
|
|||||||
/>
|
/>
|
||||||
</IconField>
|
</IconField>
|
||||||
</div>
|
</div>
|
||||||
}
|
)}
|
||||||
|
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<label htmlFor="username">Description</label>
|
<label htmlFor="username">Description</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user