Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add overflowTooltip to editableLabel #720

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat: add overflowTooltip to editableLabel
Signed-off-by: Mathieu Anderson <mathieu.anderson@aiven.io>
  • Loading branch information
Mathieu Anderson committed Nov 3, 2023
commit aeb1e3be6dc740c8ab1779ee10076a3d9c116953
5 changes: 4 additions & 1 deletion app/client/lib/koForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var koArray = require('./koArray');

var modelUtil = require('../models/modelUtil');

const { overflowTooltip } = require("app/client/ui/tooltips");

var setSaveValue = modelUtil.setSaveValue;


Expand Down Expand Up @@ -902,7 +904,8 @@ exports.editableLabel = function(valueObservable, optToggleObservable) {
return dom('div.kf_editable_label',
dom('div.kf_elabel_text',
kd.text(valueObservable),
kd.hide(isEditing)
kd.hide(isEditing),
overflowTooltip({placement: 'top'})
),
contentSizer = dom('div.elabel_content_measure'),
(!optToggleObservable ? dom.on('click', () => isEditing(true)) : null),
Expand Down
13 changes: 13 additions & 0 deletions test/client/lib/koForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ describe('koForm', function() {
});
});

describe("editableLabel", function() {
it("should bind an observable", function () {
var obs = ko.observable("Tools, projects, things and others");
var el = kf.editableLabel(obs).querySelector("div.kf_elabel_text");

assert.equal(el.textContent, "Tools, projects, things and others");
});

it("should show a tooltip when textContent overflows", function () {
// How to test this? Should it be tested here?
});
});

describe("select", function() {
it("should bind an observable", function() {
var obs = ko.observable("b");
Expand Down
Loading