@mirohq/design-system-use-press
Advanced tools
Comparing version 0.3.0-toolbar-item-use-press.3 to 0.3.0-toolbar-item-use-press.4
@@ -16,9 +16,16 @@ 'use strict'; | ||
}) => { | ||
if (disabled || preventFocusOnPress === null) { | ||
if (disabled) { | ||
return; | ||
} | ||
if (!preventFocusOnPress) { | ||
utils.focusWithoutScrolling(target); | ||
} else if (document.activeElement !== target) { | ||
document.activeElement.blur(); | ||
switch (preventFocusOnPress) { | ||
case "auto": | ||
break; | ||
case true: | ||
document.activeElement.blur(); | ||
break; | ||
case false: | ||
if (document.activeElement !== target) { | ||
utils.focusWithoutScrolling(target); | ||
} | ||
break; | ||
} | ||
@@ -25,0 +32,0 @@ }; |
@@ -12,9 +12,16 @@ import { useRef, useState, useEffect } from 'react'; | ||
}) => { | ||
if (disabled || preventFocusOnPress === null) { | ||
if (disabled) { | ||
return; | ||
} | ||
if (!preventFocusOnPress) { | ||
focusWithoutScrolling(target); | ||
} else if (document.activeElement !== target) { | ||
document.activeElement.blur(); | ||
switch (preventFocusOnPress) { | ||
case "auto": | ||
break; | ||
case true: | ||
document.activeElement.blur(); | ||
break; | ||
case false: | ||
if (document.activeElement !== target) { | ||
focusWithoutScrolling(target); | ||
} | ||
break; | ||
} | ||
@@ -21,0 +28,0 @@ }; |
@@ -57,4 +57,9 @@ import { AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties } from 'react'; | ||
disabled?: boolean; | ||
/** Whether the target should not receive focus on press. */ | ||
preventFocusOnPress?: boolean | null; | ||
/** | ||
* Controls the focus behavior on press for the target component. | ||
* - 'auto': The usePress does not manage focus on press. | ||
* - true: Prevents the target component from receiving focus when pressed. | ||
* - false: Focus is applied to the target component when pressed, without scrolling the page. | ||
*/ | ||
preventFocusOnPress?: boolean | 'auto'; | ||
/** Whether text selection should be enabled on the pressable element. */ | ||
@@ -61,0 +66,0 @@ allowTextSelectionOnPress?: boolean; |
{ | ||
"name": "@mirohq/design-system-use-press", | ||
"version": "0.3.0-toolbar-item-use-press.3", | ||
"version": "0.3.0-toolbar-item-use-press.4", | ||
"description": "", | ||
@@ -30,4 +30,4 @@ "author": "Miro", | ||
"@mirohq/design-system-use-listeners": "^0.1.1", | ||
"@mirohq/design-system-utils": "^0.14.3", | ||
"@mirohq/design-system-use-logger": "^0.1.6" | ||
"@mirohq/design-system-use-logger": "^0.1.6", | ||
"@mirohq/design-system-utils": "^0.14.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168888
1698