(e: FocusEvent)
| 308 | } |
| 309 | |
| 310 | onBlur(e: FocusEvent): void { |
| 311 | let activateButton = this.getCurrentActivateButton(); |
| 312 | // Guard activateButton non-null so this doesn't trip on the case where |
| 313 | // there's no activate button and the focused element loses focus to nothing |
| 314 | // (browsers and jsdom 26+ both set relatedTarget to null in that case). |
| 315 | if (activateButton && e.relatedTarget === activateButton) { |
| 316 | this.cancelEvent(e); |
| 317 | return; |
| 318 | } |
| 319 | |
| 320 | if (getEventTarget(e) !== this.dragTarget.element) { |
| 321 | this.cancelEvent(e); |
| 322 | } |
| 323 | |
| 324 | // If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM), |
| 325 | // restore focus back to the current drop target if any, or the original drag target. |
| 326 | if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) { |
| 327 | if (this.currentDropTarget) { |
| 328 | this.currentDropTarget.element.focus(); |
| 329 | } else { |
| 330 | this.dragTarget.element.focus(); |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | onClick(e: MouseEvent): void { |
| 336 | this.cancelEvent(e); |
no test coverage detected