Skip to content

Commit b15badc

Browse files
Added possibility to "ui_dropdown" component to delete user text in search box (#816)
* Update ui_dropdown.js - Added option msg.resetSearch to send it to frontend dropdown via emitOptions.resetSearch * Update ui-component-ctrl.js - process msg.resetSearch If resetSearch is present in msg, clear user searchTerm input in dropdown select ui component. * Update ui_dropdown.html - Added info about resetSearch Added information about msg.resetSearch (delete user search term)
1 parent f4da205 commit b15badc

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

nodes/locales/en-US/ui_dropdown.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<p>The configured value of the selected item will be returned as <code>msg.payload</code>.</p>
66
<p>Setting <code>msg.payload</code> to one of the item values will preset the choice in the dropdown.
77
If using the multi-select option then the payload should be an array of values.</p>
8+
<p>Optionally user search term can deleted if set the <code>msg.resetSearch</code> property is present and true.</p>
89
<p>Optionally the <b>Topic</b> field can be used to set the <code>msg.topic</code> property.</p>
910
<p>The Options may be configured by inputting <code>msg.options</code> containing an array.
1011
If just text then the value will be the same as the label, otherwise you can specify both by

nodes/ui_dropdown.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ module.exports = function(RED) {
111111
node.error("ERR: Invalid Options", msg);
112112
}
113113
}
114-
114+
if (msg.hasOwnProperty("resetSearch") && msg.resetSearch) {
115+
emitOptions.resetSearch = true;
116+
}
115117
if (msg.hasOwnProperty("payload")) {
116118
if (node.multiple) {
117119
if (typeof msg.payload === "string") {

src/components/ui-component/ui-component-ctrl.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ angular.module('ui').controller('uiComponentController', ['$scope', 'UiEvents',
435435

436436
// may add additional input processing for other controls
437437
var processDropDownInput = function (msg) {
438+
// If resetSearch is present, clear user searchTerm input
439+
if (msg && msg.resetSearch) {
440+
me.searchTerm = "";
441+
}
438442
// options should have the correct format see beforeEmit in ui-dropdown.js
439443
if (msg && msg.isOptionsValid) {
440444
me.item.options = msg.newOptions;

0 commit comments

Comments
 (0)