wip: deal with escape in tableeditor input/textarea

This commit is contained in:
Yohan Boniface 2024-07-10 11:47:52 +02:00
parent 9f04f56c7c
commit 4a6b271bbe

View file

@ -214,7 +214,7 @@ export default class TableEditor extends WithTemplate {
const field = `properties.${property}` const field = `properties.${property}`
const tr = event.target.closest('tr') const tr = event.target.closest('tr')
const feature = this.datalayer.getFeatureById(tr.dataset.feature) 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 }]], { const builder = new U.FormBuilder(feature, [[field, { handler }]], {
id: `umap-feature-properties_${L.stamp(feature)}`, id: `umap-feature-properties_${L.stamp(feature)}`,
}) })
@ -226,6 +226,14 @@ export default class TableEditor extends WithTemplate {
cell.innerHTML = feature.properties[property] || '' cell.innerHTML = feature.properties[property] || ''
cell.focus() cell.focus()
}) })
input.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
builder.restoreField(field)
cell.innerHTML = feature.properties[property] || ''
cell.focus()
event.stopPropagation()
}
})
} }
onKeyDown(event) { onKeyDown(event) {