MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onBlur

Method onBlur

packages/react-aria/src/dnd/DragManager.ts:310–333  ·  view source on GitHub ↗
(e: FocusEvent)

Source from the content-addressed store, hash-verified

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);

Callers 8

onBlurFunction · 0.80
onBlurWithinFunction · 0.80
onBlurFunction · 0.80
useSelectFunction · 0.80
useDateRangePickerFunction · 0.80
useDateFieldFunction · 0.80
useDatePickerFunction · 0.80

Calls 4

cancelEventMethod · 0.95
getEventTargetFunction · 0.90
focusMethod · 0.80

Tested by

no test coverage detected