1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3155 from node-red/config-select

Ensure config-node select inherits width properly from input
This commit is contained in:
Nick O'Leary 2021-09-29 19:14:12 +01:00 committed by GitHub
commit 3b6d0995b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,25 +250,24 @@ RED.editor = (function() {
var newWidth = input.width(); var newWidth = input.width();
var attrStyle = input.attr('style'); var attrStyle = input.attr('style');
var m; var m;
if ((m = /width\s*:\s*(\d+(%|[a-z]+))/i.exec(attrStyle)) !== null) { if ((m = /(^|\s|;)width\s*:\s*([^;]+)/i.exec(attrStyle)) !== null) {
newWidth = m[1]; newWidth = m[2].trim();
} else { } else {
newWidth = "70%"; newWidth = "70%";
} }
var outerWrap = $("<div></div>").css({display:'inline-block',position:'relative'}); var outerWrap = $("<div></div>").css({
var selectWrap = $("<div></div>").css({position:'absolute',left:0,right:'40px'}).appendTo(outerWrap); width: newWidth,
var select = $('<select id="'+prefix+'-'+property+'"></select>').appendTo(selectWrap); display:'inline-flex'
});
outerWrap.width(newWidth).height(input.height()); var select = $('<select id="'+prefix+'-'+property+'"></select>').appendTo(outerWrap);
if (outerWrap.width() === 0) {
outerWrap.width("70%");
}
input.replaceWith(outerWrap); input.replaceWith(outerWrap);
// set the style attr directly - using width() on FF causes a value of 114%... // set the style attr directly - using width() on FF causes a value of 114%...
select.attr('style',"width:100%"); select.css({
'flex-grow': 1
});
updateConfigNodeSelect(property,type,node[property],prefix); updateConfigNodeSelect(property,type,node[property],prefix);
$('<a id="'+prefix+'-lookup-'+property+'" class="red-ui-button"><i class="fa fa-pencil"></i></a>') $('<a id="'+prefix+'-lookup-'+property+'" class="red-ui-button"><i class="fa fa-pencil"></i></a>')
.css({position:'absolute',right:0,top:0}) .css({"margin-left":"10px"})
.appendTo(outerWrap); .appendTo(outerWrap);
$('#'+prefix+'-lookup-'+property).on("click", function(e) { $('#'+prefix+'-lookup-'+property).on("click", function(e) {
showEditConfigNodeDialog(property,type,select.find(":selected").val(),prefix); showEditConfigNodeDialog(property,type,select.find(":selected").val(),prefix);