Check if getElement() is undefined before adding focus listener (Canvas) (#8498)

This commit is contained in:
Florian Bischof
2022-10-01 11:10:14 +02:00
committed by Vladimir Agafonkin
parent 00416a546f
commit 579c90d271
2 changed files with 24 additions and 6 deletions

View File

@ -387,15 +387,21 @@ Layer.include({
},
_addFocusListenersOnLayer: function (layer) {
DomEvent.on(layer.getElement(), 'focus', function () {
this._tooltip._source = layer;
this.openTooltip();
}, this);
DomEvent.on(layer.getElement(), 'blur', this.closeTooltip, this);
var el = layer.getElement();
if (el) {
DomEvent.on(el, 'focus', function () {
this._tooltip._source = layer;
this.openTooltip();
}, this);
DomEvent.on(el, 'blur', this.closeTooltip, this);
}
},
_setAriaDescribedByOnLayer: function (layer) {
layer.getElement().setAttribute('aria-describedby', this._tooltip._container.id);
var el = layer.getElement();
if (el) {
el.setAttribute('aria-describedby', this._tooltip._container.id);
}
},