Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion inst/assets/js/blockr-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ Blockr.tooltip = (() => {
// The attribute can go again (a name editable only in a mode).
if (!el.hasAttribute('data-blockr-editable')) return null;
const hint = el.getAttribute('data-blockr-editable') || HINT;
return Blockr.cutOff(el) ? { name: (el.textContent || '').trim(), label: hint } : hint;
// An <input> holds its text in `value`, not in its content.
const text = el instanceof HTMLInputElement ? el.value : el.textContent;
return Blockr.cutOff(el) ? { name: (text || '').trim(), label: hint } : hint;
});
};

Expand Down
13 changes: 13 additions & 0 deletions tests/js/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@ test('editable text names its gesture, the default or its own', (newWindow) => {
win.close();
});

test('a cut-off editable <input> names its value', (newWindow) => {
const win = newWindow();
const input = win.document.createElement('input');
input.value = 'Patients with a serious adverse event';
input.setAttribute('data-blockr-editable', '');
win.document.body.append(input);
Object.defineProperty(input, 'clientWidth', { value: 80 });
Object.defineProperty(input, 'scrollWidth', { value: 240 });
over(win, input);
assert.match(win.Blockr.tooltip.text(input), /Patients with a serious adverse event/);
win.close();
});

test('a native title that reaches the page is left to its owner', (newWindow) => {
// Blockr markup carries data-blockr-tooltip instead. Rewriting other
// code's titles froze them (a title cleared later kept its old card) and
Expand Down
Loading