I have created a context menu with a delete button as follows:
$ < go.Panel > ( 'ContextMenuButton', { 'ButtonBorder.fill': '#F1F1F1' }, { click: (e, obj) => { const ad = obj.part as go.Adornment; const node = ad.adornedPart as go.Node; this.commentNode = node; this.commentDeleted.emit(node); } }, new go.Binding('ButtonBorder.fill', '', () => { const commentAct = this.commentNode.data as Activity; console.log( 'Delete comment button binding: ' + commentAct.comments ); return commentAct && commentAct.comments && commentAct.comments !== '' ? '#F1F1F1' : 'transparent'; }), $( go.TextBlock, 'Delete', { font: this.defaultFont, desiredSize: new go.Size(50, 25), alignmentFocus: go.Spot.Center, margin: new go.Margin(10, 0, 0, 18) }, new go.Binding('stroke', '', () => { const commentAct = this.commentNode.data as Activity; console.log( 'Delete button stroke binding: ' + commentAct.comments ); return commentAct && commentAct.comments && commentAct.comments !== '' ? 'black' : 'lightgrey'; }) ) ),
On initial load of diagram, when I opened the context menu for the first time, I did not even see the console.log() statements printing to the console.
Needless to say, commentAct.comments should be empty on initial load, I expected the delete button to be transparent with lightgrey stroke, but I saw #F1F1F1 background color and black stroke.
Once I set commentAct.comments to a non-empty string, then reset commentAct.comments to the empty string, then the Binding correctly sets the background color to transparent and the stroke to lightgrey.
Can you please advise on the reason and the fix?
Thanks.