Et2VfsSelectDialog: In Save As mode, selecting a file changes filename to the selected name

Plus some vertical spacing fixes
This commit is contained in:
nathan 2024-03-21 09:30:58 -06:00
parent b429434010
commit 1bfd3ac6fe
3 changed files with 13 additions and 3 deletions

View File

@ -8,6 +8,7 @@ export default css`
et2-dialog::part(body) {
display: flex;
flex-direction: column;
gap: var(--sl-spacing-small);
}
.et2_toolbar {

View File

@ -33,7 +33,7 @@ When the user closes the dialog, getComplete() will return the selected files.
```js
const dialog = this.et2.getWidgetById("files");
let files = await dialog.getComplete();
let [button, files] = await dialog.getComplete();
```
This is probably the best way to get files (or directories) that you then want to do something with on the client. See

View File

@ -583,13 +583,22 @@ export class Et2VfsSelectDialog
if(file && !file.disabled)
{
// Can't select a directory normally, can't select anything in "saveas"
if(file.value.isDir && this.mode != "select-dir" || this.mode == "saveas")
// Can't select a directory normally
if(file.value.isDir && this.mode != "select-dir")
{
event.preventDefault();
event.stopPropagation();
return;
}
// can't select anything in "saveas", but set the file name
else if(this.mode == "saveas")
{
this._filenameNode.value = file.value.name;
event.preventDefault();
event.stopPropagation();
this.updateComplete.then(() => this._filenameNode.focus());
return;
}
// Set focus after updating so the value is announced by screen readers
//this.updateComplete.then(() => this.displayInput.focus({ preventScroll: true }));
}