diff --git a/src/client/managers/widgets.mjs b/src/client/managers/widgets.mjs index 16bc9563..cf569d9a 100644 --- a/src/client/managers/widgets.mjs +++ b/src/client/managers/widgets.mjs @@ -271,13 +271,16 @@ class WidgetManager extends EventEmitter { /* scopable: return matching widgets only for the closest scope with results */ - if (scope) { + if (scope && scope.length) { + if (!Array.isArray(scope)) scope = [scope] for (var prefix of scope) { var prefixedId = Array.isArray(id) ? id.map(i=>prefix + i) : prefix + id + var widgets = this.getWidgetBy(prefixedId, this.idRoute) if (widgets.length) return widgets } + return [] } return this.getWidgetBy(id, this.idRoute) diff --git a/src/client/widgets/common/widget.mjs b/src/client/widgets/common/widget.mjs index 0c89f166..5c76e3c7 100644 --- a/src/client/widgets/common/widget.mjs +++ b/src/client/widgets/common/widget.mjs @@ -431,9 +431,11 @@ class Widget extends EventEmitter { parent = parent.parent } while (parent.meta.scopable || parent.getProp('scopedId')) for (var i=0; i < this.scopes.length; i++) { - this.scopes[i] = this.scopes.slice(i).reverse().join('/') + this.scopes[i] = this.scopes.slice(i).reverse().join('/') + '/' } } + // include global scope + if (this.scopes.length) this.scopes.push('') // @{props} links lists this.linkedProps = {} @@ -549,11 +551,11 @@ class Widget extends EventEmitter { /* scopable: attempt to resolve scoped widget updates against ids in advanced syntax blocks */ - if (this.meta.scopable) { + if (this.scopes.length) { var unprefixedId for (var p of this.scopes) { if (id.includes(p)) { - unprefixedId = id.replace(p + '/', '') + unprefixedId = id.replace(p, '') if (this.nestedLinkedProps[unprefixedId] || linkedProps[unprefixedId]) { id = unprefixedId break @@ -957,7 +959,7 @@ class Widget extends EventEmitter { */ case 'id': if (this.scopes.length) { - propValue = this.scopes[0] + '/' + propValue + propValue = this.scopes[0] + propValue } break } diff --git a/src/client/widgets/containers/clone.mjs b/src/client/widgets/containers/clone.mjs index 7005d770..287a4ba5 100644 --- a/src/client/widgets/containers/clone.mjs +++ b/src/client/widgets/containers/clone.mjs @@ -123,7 +123,10 @@ class Clone extends Container() { .filter(w=>this.isValidCloneTarget(w)) target = widgets[0] - if (!target) continue + if (!target) { + rank++ + continue + } for (var w of widgets) { // when duplicating clones pointing to an object with a static id, @@ -135,7 +138,7 @@ class Clone extends Container() { } } - if (target && (rank < this.targetRank || this.targetRank == null)) { + if (rank < this.targetRank || this.targetRank == null) { var clone = this.children[0] @@ -153,11 +156,9 @@ class Clone extends Container() { this.updateClone() } - - return } - rank++ + return } diff --git a/src/client/widgets/sliders/scrollbar.mjs b/src/client/widgets/sliders/scrollbar.mjs index 1f355ae6..6da7bc07 100644 --- a/src/client/widgets/sliders/scrollbar.mjs +++ b/src/client/widgets/sliders/scrollbar.mjs @@ -51,7 +51,6 @@ export default class Scrollbar extends StaticProperties(Fader, { this.rangeVals[1] = 0 } - this.getScrollTarget() widgetManager.on('widget-created', (e)=>{ @@ -59,13 +58,15 @@ export default class Scrollbar extends StaticProperties(Fader, { if (!this.scopes.length && this.scrollTarget) return var {id, widget} = e - if (id.includes(this.getProp('widgetId')) && widget.getProp('scroll')) { + this.getScrollTarget() } }, {context: this}) + this.getScrollTarget() + } getScrollTarget() { @@ -79,16 +80,19 @@ export default class Scrollbar extends StaticProperties(Fader, { .filter(w=>w.getProp('scroll')) target = widgets[0] - if (!target) continue + if (!target) { + rank++ + continue + } - if (target && (rank < this.targetRank || this.targetRank == null)) { + if (rank < this.targetRank || this.targetRank == null) { + if (this.scopes.length) this.log(rank) this.unbindTarget() this.bindTarget(target, rank) - return } - rank++ + return }