Skip to content

Commit

Permalink
wip: deal with escape in tableeditor input/textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Jul 11, 2024
1 parent 9f04f56 commit 4a6b271
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion umap/static/umap/js/modules/tableeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default class TableEditor extends WithTemplate {
const field = `properties.${property}`
const tr = event.target.closest('tr')
const feature = this.datalayer.getFeatureById(tr.dataset.feature)
const handler = property === 'description' ? 'Textarea' : 'Input'
const handler = property === 'description' ? 'Textarea' : 'BlurInput'
const builder = new U.FormBuilder(feature, [[field, { handler }]], {
id: `umap-feature-properties_${L.stamp(feature)}`,
})
Expand All @@ -226,6 +226,14 @@ export default class TableEditor extends WithTemplate {
cell.innerHTML = feature.properties[property] || ''
cell.focus()
})
input.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
builder.restoreField(field)
cell.innerHTML = feature.properties[property] || ''
cell.focus()
event.stopPropagation()
}
})
}

onKeyDown(event) {
Expand Down

0 comments on commit 4a6b271

Please sign in to comment.