From 8a5eda9c1f0dc5bde322d2ded6cbb33f2018cc7f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 2 Oct 2021 23:24:41 +0100 Subject: [PATCH] Ensure type select button is not focussable when TypedInput only has one type --- .../editor-client/src/js/ui/common/typedInput.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js index 187dc066c..41c731e3b 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js @@ -583,7 +583,7 @@ var height = relativeTo.height(); var menuHeight = menu.height(); var top = (height+pos.top); - if (top+menuHeight > $(window).height()) { + if (top+menuHeight-$(document).scrollTop() > $(window).height()) { top -= (top+menuHeight)-$(window).height()+5; } if (top < 0) { @@ -692,8 +692,10 @@ }); if (this.typeList.length < 2) { this.selectTrigger.attr("tabindex", -1) + this.selectTrigger.on("mousedown.red-ui-typedInput-focus-block", function(evt) { evt.preventDefault(); }) } else { this.selectTrigger.attr("tabindex", 0) + this.selectTrigger.off("mousedown.red-ui-typedInput-focus-block") } this.selectTrigger.toggleClass("disabled", this.typeList.length === 1); this.selectTrigger.find(".fa-caret-down").toggle(this.typeList.length > 1) @@ -707,6 +709,11 @@ this.propertyType = null; 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) { this.uiWidth = desiredWidth;