use text width instead of number of characters for deciding select field width of switch node rule

This commit is contained in:
Hiroyasu Nishiyama 2022-05-08 12:32:07 +09:00
parent 8706998c8c
commit abb81a0bac
1 changed files with 7 additions and 2 deletions

View File

@ -247,6 +247,8 @@
var row2 = $('<div/>',{style:"display: flex; padding-top: 5px; padding-left: 175px;"}).appendTo(inputRows);
var row3 = $('<div/>',{style:"display: flex; padding-top: 5px; align-items: center"}).appendTo(inputRows);
var row4 = $('<div/>',{style:"visibility: hidden; height: 0px;"}).appendTo(inputRows);
var textSpan = $("<span/>").appendTo(row4);
var selectField = $('<select/>',{style:"width:120px; text-align: center;"}).appendTo(row);
var group0 = $('<optgroup/>', { label: "value rules" }).appendTo(selectField);
for (var d in operators) {
@ -340,9 +342,12 @@
row3.hide();
}
var selectedLabel = selectField.find("option:selected").text();
if (selectedLabel.length <= 5) {
textSpan.text(selectedLabel);
var width = textSpan.width();
if (width <= 30) {
selectField.outerWidth(60);
} else if (selectedLabel.length < 12) {
} else if (width <= 85) {
selectField.outerWidth(120);
} else {
selectField.width("auto")