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

Ensure type select button is not focussable when TypedInput only has one type

This commit is contained in:
Nick O'Leary 2021-10-02 23:24:41 +01:00
parent f62040f0ec
commit 8a5eda9c1f
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -583,7 +583,7 @@
var height = relativeTo.height(); var height = relativeTo.height();
var menuHeight = menu.height(); var menuHeight = menu.height();
var top = (height+pos.top); var top = (height+pos.top);
if (top+menuHeight > $(window).height()) { if (top+menuHeight-$(document).scrollTop() > $(window).height()) {
top -= (top+menuHeight)-$(window).height()+5; top -= (top+menuHeight)-$(window).height()+5;
} }
if (top < 0) { if (top < 0) {
@ -692,8 +692,10 @@
}); });
if (this.typeList.length < 2) { if (this.typeList.length < 2) {
this.selectTrigger.attr("tabindex", -1) this.selectTrigger.attr("tabindex", -1)
this.selectTrigger.on("mousedown.red-ui-typedInput-focus-block", function(evt) { evt.preventDefault(); })
} else { } else {
this.selectTrigger.attr("tabindex", 0) this.selectTrigger.attr("tabindex", 0)
this.selectTrigger.off("mousedown.red-ui-typedInput-focus-block")
} }
this.selectTrigger.toggleClass("disabled", this.typeList.length === 1); this.selectTrigger.toggleClass("disabled", this.typeList.length === 1);
this.selectTrigger.find(".fa-caret-down").toggle(this.typeList.length > 1) this.selectTrigger.find(".fa-caret-down").toggle(this.typeList.length > 1)
@ -707,6 +709,11 @@
this.propertyType = null; this.propertyType = null;
this.type(currentType); this.type(currentType);
} }
if (this.typeList.length === 1 && !this.typeList[0].icon && (!this.typeList[0].label || this.typeList[0].showLabel === false)) {
this.selectTrigger.hide()
} else {
this.selectTrigger.show()
}
}, },
width: function(desiredWidth) { width: function(desiredWidth) {
this.uiWidth = desiredWidth; this.uiWidth = desiredWidth;