fix(android): the tap lands on the drawing, not on the button

Copying a password or a username opened the entry instead - about half the
time, which is the worst kind of failure to diagnose. Since those buttons
carry an icon, the tap target is the <svg> or one of its strokes, so reading
the attribute off the target returned null and the handler fell through to
"open". A finger landing sometimes on the glyph and sometimes on the margin
made it look random. Both handlers now resolve to the button first.

The new-entry form gets a folder, like the editor: an entry filed from the
start saves having to move it.

And a folder can now be created, not only chosen. Filing an entry under a
name is not enough - it is `folders` that fills the desktop's column, and a
name missing from it leaves the entry in a folder nothing displays, looking
lost. The two now go together, in one place, for both editing and creation.
'All' is never registered: it is the default, not a folder.
This commit is contained in:
r-zakarya
2026-08-21 22:11:14 +01:00
parent 0badc5fcfc
commit 1dba5d392f
3 changed files with 96 additions and 11 deletions
+52 -4
View File
@@ -562,8 +562,14 @@ function renderRows() {
document.getElementById('rows').addEventListener('click', function (ev) {
var row = ev.target.closest('.row');
if (!row) return;
var copy = ev.target.getAttribute('data-copy');
if (copy) send('copy?i=' + row.getAttribute('data-i') + '&f=' + copy);
// REMONTER AU BOUTON. Depuis que ces boutons portent un dessin, la cible de
// l'appui est le <svg> ou l'un de ses traits, pas le bouton : lire
// l'attribut sur la cible rendait null, et l'appui ouvrait l'entree au lieu
// de copier. Le doigt tombant tantot sur le glyphe tantot sur la marge, cela
// ne ratait qu'une fois sur deux - la pire des pannes a diagnostiquer.
var btn = ev.target.closest('[data-copy]');
if (btn) send('copy?i=' + row.getAttribute('data-i')
+ '&f=' + btn.getAttribute('data-copy'));
else send('open?i=' + row.getAttribute('data-i'));
});
@@ -677,7 +683,10 @@ function renderDetail(d) {
}
document.getElementById('fields').addEventListener('click', function (ev) {
var t = ev.target, k = t.getAttribute('data-show');
// Meme raison que dans la liste : le dessin recoit l'appui, le bouton porte
// l'intention. Tout ce qui suit lit et ecrit sur le bouton.
var t = ev.target.closest('button') || ev.target;
var k = t.getAttribute('data-show');
if (t.id === 'del') {
if (t.getAttribute('data-armed') === null) {
t.setAttribute('data-armed', '1');
@@ -778,9 +787,31 @@ function editorControl(k) {
html += '<option value="' + esc(names[i]) + '"'
+ (names[i] === val ? ' selected' : '') + '>' + esc(names[i])
+ '</option>';
// CHOISIR NE SUFFIT PAS : le premier dossier d'un coffre n'existe pas encore,
// et rien ne permettait de le nommer. Cette option echange la liste contre un
// champ libre, sans quitter l'editeur.
html += '<option value="' + NEW_FOLDER + '">+ new folder</option>';
return html + '</select>';
}
var NEW_FOLDER = '\u0001new';
// Le choix "+ new folder" remplace la liste par un champ. Delegue sur #fields
// parce que le controle nait et meurt avec l'editeur.
document.getElementById('fields').addEventListener('change', function (ev) {
if (ev.target.id !== 'editval' || ev.target.value !== NEW_FOLDER) return;
var line = ev.target.parentNode;
var input = document.createElement('input');
input.className = 'field-in';
input.id = 'editval';
input.setAttribute('placeholder', 'folder name');
input.setAttribute('autocomplete', 'off');
input.setAttribute('autocapitalize', 'none');
input.style.cssText = 'margin:0;flex:1;min-width:0;width:auto';
line.replaceChild(input, ev.target);
input.focus();
});
// EDITEUR EN PLACE, pas window.prompt : une invite JavaScript demande au
// moteur un WebChromeClient que FMX ne fournit pas, et prompt() rend alors
// null sans un mot - le bouton semblerait ne rien faire.
@@ -895,6 +926,20 @@ addEventListener('keydown', function (ev) {
// place a l'ecran, et c'est exactement ce que cette vue veut dire.
var newKind = 'login';
/// Le dossier a la creation. Le meme choix que dans l'editeur, et pour la
/// meme raison : une entree rangee des le depart evite d'avoir a la deplacer.
function newFolderField() {
var names = ['All'], i;
for (i = 0; i < folders.length; i++)
if (folders[i] && names.indexOf(folders[i]) < 0) names.push(folders[i]);
var html = '<div class="field"><div class="cap">Folder</div><div class="line">'
+ '<select class="field-in" id="nFolder"'
+ ' style="margin:0;flex:1;min-width:0;width:auto">';
for (i = 0; i < names.length; i++)
html += '<option value="' + esc(names[i]) + '">' + esc(names[i]) + '</option>';
return html + '</select></div></div>';
}
function newField(id, label, type) {
return '<div class="field"><div class="cap">' + label + '</div>'
+ '<div class="line"><input class="field-in" id="' + id + '" type="'
@@ -911,6 +956,7 @@ function openNewEntry() {
'<div class="field"><div class="cap">Kind</div><div class="line">'
+ '<button class="btn main" data-kind="login">Login</button>'
+ '<button class="btn" data-kind="note">Note</button></div></div>'
+ newFolderField()
+ newField('nTitle', 'Name', 'text')
+ newField('nSite', 'Site', 'text')
+ newField('nUser', 'Username', 'text')
@@ -953,7 +999,9 @@ document.getElementById('fields').addEventListener('click', function (ev) {
if (ev.target.id !== 'nSave') return;
var v = function (id) { return document.getElementById(id).value.trim(); };
ev.target.disabled = true;
send('newentry?t=' + encodeURIComponent(v('nTitle'))
var fold = document.getElementById('nFolder');
send('newentry?d=' + encodeURIComponent(fold ? fold.value : 'All')
+ '&t=' + encodeURIComponent(v('nTitle'))
+ '&s=' + encodeURIComponent(v('nSite'))
+ '&u=' + encodeURIComponent(v('nUser'))
+ '&p=' + encodeURIComponent(document.getElementById('nPwd').value)