diff --git a/jpro-file/src/main/java/one/jpro/platform/file/picker/BaseFilePicker.java b/jpro-file/src/main/java/one/jpro/platform/file/picker/BaseFilePicker.java index 4c47bc5d..ed9e08ed 100644 --- a/jpro-file/src/main/java/one/jpro/platform/file/picker/BaseFilePicker.java +++ b/jpro-file/src/main/java/one/jpro/platform/file/picker/BaseFilePicker.java @@ -72,6 +72,15 @@ public final void setSelectedExtensionFilter(final ExtensionFilter filter) { selectedExtensionFilterProperty().setValue(filter); } + final ExtensionFilter findSelectedFilter() { + ExtensionFilter selectedFilter = getSelectedExtensionFilter(); + if (selectedFilter == null || !extensionFilters.contains(selectedFilter)) { + return extensionFilters.isEmpty() ? null : extensionFilters.get(0); + } else { + return selectedFilter; + } + } + final void synchronizeSelectedExtensionFilter(FileChooser fileChooser) { fileChooser.selectedExtensionFilterProperty() .addListener(new WeakChangeListener<>(getNativeSelectedExtensionFilterChangeListener())); diff --git a/jpro-file/src/main/java/one/jpro/platform/file/picker/WebFileSavePicker.java b/jpro-file/src/main/java/one/jpro/platform/file/picker/WebFileSavePicker.java index 757ce30c..2a1ff33f 100644 --- a/jpro-file/src/main/java/one/jpro/platform/file/picker/WebFileSavePicker.java +++ b/jpro-file/src/main/java/one/jpro/platform/file/picker/WebFileSavePicker.java @@ -128,8 +128,8 @@ public final ObjectProperty selectedExtensionFilterProperty() { @Override final void showDialog() { final String fileName = getInitialFileName() == null ? "filename" : getInitialFileName(); - final ExtensionFilter fileExtension = getSelectedExtensionFilter(); - final String fileType = fileExtension == null ? "" : fileExtension.extensions().get(0); + final ExtensionFilter extensionFilter = findSelectedFilter(); + final String fileType = extensionFilter == null ? "" : extensionFilter.extensions().get(0); final Function> onFileSelected = getOnFileSelected(); if (onFileSelected != null) { try {