Merge pull request #1535 from umap-project/empty-fileinput

fix: empty file input when closing the importer panel
This commit is contained in:
Yohan Boniface 2024-01-29 12:47:15 +01:00 committed by GitHub
commit dee5af33a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 },
this.fileBox
)
this.map.ui.once('panel:closed', () => (this.fileInput.value = null))
this.urlInput = L.DomUtil.element(
'input',
{ 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")
expect(button).to_be_visible()
button.click()
file_input = page.locator("input[type='file']")
with page.expect_file_chooser() as fc_info:
page.locator("input[type='file']").click()
file_input.click()
file_chooser = fc_info.value
path = Path(__file__).parent.parent / "fixtures/display_on_load.umap"
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)
nonloaded = page.locator(".umap-browse-datalayers li.off")
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):