fix: empty file input when closing the importer panel

Otherwise, we cannot import anything else than a file, even when
closing and reopening the panel. User needs to refresh the page.
This commit is contained in:
Yohan Boniface 2024-01-16 12:28:59 +01:00
parent 3e5927f65e
commit 4227e171f3
2 changed files with 7 additions and 1 deletions

View file

@ -16,6 +16,7 @@ L.U.Importer = L.Class.extend({
{ type: 'file', multiple: 'multiple', autofocus: true }, { type: 'file', multiple: 'multiple', autofocus: true },
this.fileBox this.fileBox
) )
this.map.ui.once('panel:closed', () => (this.fileInput.value = null))
this.urlInput = L.DomUtil.element( this.urlInput = L.DomUtil.element(
'input', 'input',
{ type: 'text', placeholder: L._('Provide an URL here') }, { type: 'text', placeholder: L._('Provide an URL here') },

View file

@ -11,8 +11,9 @@ def test_umap_import_from_file(live_server, datalayer, page):
button = page.get_by_title("Import data") button = page.get_by_title("Import data")
expect(button).to_be_visible() expect(button).to_be_visible()
button.click() button.click()
file_input = page.locator("input[type='file']")
with page.expect_file_chooser() as fc_info: with page.expect_file_chooser() as fc_info:
page.locator("input[type='file']").click() file_input.click()
file_chooser = fc_info.value file_chooser = fc_info.value
path = Path(__file__).parent.parent / "fixtures/display_on_load.umap" path = Path(__file__).parent.parent / "fixtures/display_on_load.umap"
file_chooser.set_files(path) file_chooser.set_files(path)
@ -23,6 +24,10 @@ def test_umap_import_from_file(live_server, datalayer, page):
expect(layers).to_have_count(3) expect(layers).to_have_count(3)
nonloaded = page.locator(".umap-browse-datalayers li.off") nonloaded = page.locator(".umap-browse-datalayers li.off")
expect(nonloaded).to_have_count(1) expect(nonloaded).to_have_count(1)
assert file_input.input_value()
# Close the import panel
page.keyboard.press("Escape")
assert not file_input.input_value()
def test_umap_import_geojson_from_textarea(live_server, datalayer, page): def test_umap_import_geojson_from_textarea(live_server, datalayer, page):