Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
46 changes: 46 additions & 0 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2697,6 +2697,52 @@
.addClass(className.label)
.attr('data-' + metadata.value, value)
.html(templates.label(value, text, settings));
if (settings.allowAdditions) {
$label.on ("click", function(e) {
if (e.target !== this || $(this).hasClass('editing')) {
return;
}
$(this).addClass('editing');
$(this).html($(this).children())
$(this).children().hide();
let inputDiv = $('<input type="text" value="' + $(this).attr('data-value') + '"></div>')
Comment thread Fixed
inputDiv.on('keydown', function(e) {
// Prevent parent from acting on Backspace/Delete while typing
if (e.key === 'Backspace' || e.key === 'Delete') {
e.stopPropagation();
}
if (e.key === 'Enter') {
e.stopPropagation();
$(this).trigger('blur');
}
});
inputDiv.on('blur', function() {
let input = $(this);
let container = input.parent()

let oldVal = container.attr('data-value');
let newVal = input.val();
if (!(input.val()).trim()) {
module.remove.activeLabels(container);
return
}
let userVal = module.is.userValue()
if (oldVal !== newVal && !userVal) {
let $activeItem = $menu.children('.' + className.active).eq(0)
module.remove.activeLabels(container);
module.add.label(newVal, newVal, true);
module.add.value(newVal, newVal, $activeItem, false);
} else {
container.prepend(input.val())
Comment thread Fixed
container.removeClass('editing');
input.remove()
container.children('.close.icon, .delete.icon').show();
}
})
$(this).prepend(inputDiv)
inputDiv.trigger("focus")
})
}
$label = settings.onLabelCreate.call($label, value, text);

if (module.has.label(value)) {
Expand Down
11 changes: 11 additions & 0 deletions src/definitions/modules/dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,17 @@ select.ui.dropdown {
.ui.multiple.search.dropdown@{notSelection} > input.search:first-child {
min-width: @multipleSearchMinWidth;
}

/* Edited label close/delete icon positioning */
.ui.multiple.search.dropdown > .ui.label.editing > .close.icon,
.ui.multiple.search.dropdown > .ui.label.editing > .delete.icon {
margin: .3em 0 0 .5em;
}

.ui.multiple.search.dropdown > .ui.label > input[type=text] {
padding: 1px;
vertical-align: baseline;
}
}
}

Expand Down