I’m implementing accessibility features for interactive elements within my node templates. I’m using a custom property with underscore prefix to store ARIA labels:
$(go.Panel, 'Auto',
{
name: 'endNodeButton',
_ariaLabel: 'focus is on the end node', // custom property for screen reader
click: function(e, obj) {
console.log('Button clicked');
}
},
// ... shapes
)
Then in my keyboard handler, I read this property:
labelElement.textContent = obj._ariaLabel;
Is this the recommended approach for storing custom accessibility metadata on GraphObjects?
Are you aware of the new accessibility features in GoJS 3.1? I don’t think they will interfere with what you are doing (just my guess), but you should be aware of the functionality built into the new CommandHandler.
Most developers these days are using tools such as TypeScript (which did not exist when we released GoJS 1.0) and smart editors, and thus they are not using GraphObject.make as you are, so they get compile or edit time errors when setting mis-named properties to mis-typed values. That is why we added the GraphObject.attach method. GraphObject | GoJS API
Your code could instead be:
new go.Panel('Auto', {
name: 'endNodeButton',
click: (e, obj) => {
console.log('Button clicked');
}
})
.attach({
_ariaLabel: 'focus is on the end node', // custom property for screen reader
})
.add(
// ... shapes
)
Also, have you looked at the accessibility features in GoJS 3.1? If you use them, it is fairly easy to help screen readers.