@react-aria/selection
Advanced tools
Comparing version 3.0.0-nightly-835f0aa1b-250107 to 3.0.0-nightly-873f6fe9a-250125
@@ -215,6 +215,6 @@ var $ee0bdf4faa47f2a8$exports = require("./utils.main.js"); | ||
var _delegate_getLastKey, _delegate_getFirstKey; | ||
let navigateToFirstKey = (key)=>{ | ||
let navigateToKey = (key)=>{ | ||
if (key != null) { | ||
manager.setFocusedKey(key); | ||
if (selectOnFocus) manager.replaceSelection(key); | ||
if (selectOnFocus && !manager.isSelected(key)) manager.replaceSelection(key); | ||
} | ||
@@ -227,4 +227,4 @@ }; | ||
var _manager_lastSelectedKey, _manager_firstSelectedKey; | ||
if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)); | ||
else navigateToFirstKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)); | ||
if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)); | ||
else navigateToKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)); | ||
} else if (!isVirtualized && scrollRef.current) { | ||
@@ -267,11 +267,16 @@ // Restore the scroll position to what it was before. | ||
let updateActiveDescendant = (0, $bT8Bh$reactariautils.useEffectEvent)(()=>{ | ||
var _delegate_getFirstKey, _ref_current; | ||
var _delegate_getFirstKey; | ||
var _delegate_getFirstKey1; | ||
let keyToFocus = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null; | ||
// If no focusable items exist in the list, make sure to clear any activedescendant that may still exist | ||
if (keyToFocus == null) (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(new CustomEvent((0, $bT8Bh$reactariautils.UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
})); | ||
else { | ||
if (keyToFocus == null) { | ||
var _ref_current; | ||
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(new CustomEvent((0, $bT8Bh$reactariautils.UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
})); | ||
// If there wasn't a focusable key but the collection had items, then that means we aren't in an intermediate load state and all keys are disabled. | ||
// Reset shouldVirtualFocusFirst so that we don't erronously autofocus an item when the collection is filtered again. | ||
if (manager.collection.size > 0) shouldVirtualFocusFirst.current = false; | ||
} else { | ||
manager.setFocusedKey(keyToFocus); | ||
@@ -278,0 +283,0 @@ // Only set shouldVirtualFocusFirst to false if we've successfully set the first key as the focused key |
@@ -209,6 +209,6 @@ import {isNonContiguousSelectionModifier as $feb5ffebff200149$export$d3e3bd3e26688c04} from "./utils.module.js"; | ||
var _delegate_getLastKey, _delegate_getFirstKey; | ||
let navigateToFirstKey = (key)=>{ | ||
let navigateToKey = (key)=>{ | ||
if (key != null) { | ||
manager.setFocusedKey(key); | ||
if (selectOnFocus) manager.replaceSelection(key); | ||
if (selectOnFocus && !manager.isSelected(key)) manager.replaceSelection(key); | ||
} | ||
@@ -221,4 +221,4 @@ }; | ||
var _manager_lastSelectedKey, _manager_firstSelectedKey; | ||
if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)); | ||
else navigateToFirstKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)); | ||
if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)); | ||
else navigateToKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)); | ||
} else if (!isVirtualized && scrollRef.current) { | ||
@@ -261,11 +261,16 @@ // Restore the scroll position to what it was before. | ||
let updateActiveDescendant = (0, $3H3GQ$useEffectEvent)(()=>{ | ||
var _delegate_getFirstKey, _ref_current; | ||
var _delegate_getFirstKey; | ||
var _delegate_getFirstKey1; | ||
let keyToFocus = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null; | ||
// If no focusable items exist in the list, make sure to clear any activedescendant that may still exist | ||
if (keyToFocus == null) (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(new CustomEvent((0, $3H3GQ$UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
})); | ||
else { | ||
if (keyToFocus == null) { | ||
var _ref_current; | ||
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(new CustomEvent((0, $3H3GQ$UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
})); | ||
// If there wasn't a focusable key but the collection had items, then that means we aren't in an intermediate load state and all keys are disabled. | ||
// Reset shouldVirtualFocusFirst so that we don't erronously autofocus an item when the collection is filtered again. | ||
if (manager.collection.size > 0) shouldVirtualFocusFirst.current = false; | ||
} else { | ||
manager.setFocusedKey(keyToFocus); | ||
@@ -272,0 +277,0 @@ // Only set shouldVirtualFocusFirst to false if we've successfully set the first key as the focused key |
{ | ||
"name": "@react-aria/selection", | ||
"version": "3.0.0-nightly-835f0aa1b-250107", | ||
"version": "3.0.0-nightly-873f6fe9a-250125", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,8 +25,8 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/focus": "3.0.0-nightly-835f0aa1b-250107", | ||
"@react-aria/i18n": "3.0.0-nightly-835f0aa1b-250107", | ||
"@react-aria/interactions": "3.0.0-nightly-835f0aa1b-250107", | ||
"@react-aria/utils": "3.0.0-nightly-835f0aa1b-250107", | ||
"@react-stately/selection": "3.0.0-nightly-835f0aa1b-250107", | ||
"@react-types/shared": "3.0.0-nightly-835f0aa1b-250107", | ||
"@react-aria/focus": "3.0.0-nightly-873f6fe9a-250125", | ||
"@react-aria/i18n": "3.0.0-nightly-873f6fe9a-250125", | ||
"@react-aria/interactions": "3.0.0-nightly-873f6fe9a-250125", | ||
"@react-aria/utils": "3.0.0-nightly-873f6fe9a-250125", | ||
"@react-stately/selection": "3.0.0-nightly-873f6fe9a-250125", | ||
"@react-types/shared": "3.0.0-nightly-873f6fe9a-250125", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -33,0 +33,0 @@ }, |
@@ -345,8 +345,7 @@ /* | ||
manager.setFocused(true); | ||
if (manager.focusedKey == null) { | ||
let navigateToFirstKey = (key: Key | undefined | null) => { | ||
let navigateToKey = (key: Key | undefined | null) => { | ||
if (key != null) { | ||
manager.setFocusedKey(key); | ||
if (selectOnFocus) { | ||
if (selectOnFocus && !manager.isSelected(key)) { | ||
manager.replaceSelection(key); | ||
@@ -361,5 +360,5 @@ } | ||
if (relatedTarget && (e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING)) { | ||
navigateToFirstKey(manager.lastSelectedKey ?? delegate.getLastKey?.()); | ||
navigateToKey(manager.lastSelectedKey ?? delegate.getLastKey?.()); | ||
} else { | ||
navigateToFirstKey(manager.firstSelectedKey ?? delegate.getFirstKey?.()); | ||
navigateToKey(manager.firstSelectedKey ?? delegate.getFirstKey?.()); | ||
} | ||
@@ -425,2 +424,8 @@ } else if (!isVirtualized && scrollRef.current) { | ||
); | ||
// If there wasn't a focusable key but the collection had items, then that means we aren't in an intermediate load state and all keys are disabled. | ||
// Reset shouldVirtualFocusFirst so that we don't erronously autofocus an item when the collection is filtered again. | ||
if (manager.collection.size > 0) { | ||
shouldVirtualFocusFirst.current = false; | ||
} | ||
} else { | ||
@@ -427,0 +432,0 @@ manager.setFocusedKey(keyToFocus); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
420074
4681
+ Added@internationalized/date@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@internationalized/message@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@internationalized/number@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@internationalized/string@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-aria/focus@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-aria/i18n@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-aria/interactions@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-aria/ssr@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-aria/utils@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-stately/collections@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-stately/selection@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-stately/utils@3.0.0-nightly-873f6fe9a-250125(transitive)
+ Added@react-types/shared@3.0.0-nightly-873f6fe9a-250125(transitive)
- Removed@internationalized/date@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@internationalized/message@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@internationalized/number@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@internationalized/string@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-aria/focus@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-aria/i18n@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-aria/interactions@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-aria/ssr@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-aria/utils@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-stately/collections@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-stately/selection@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-stately/utils@3.0.0-nightly-835f0aa1b-250107(transitive)
- Removed@react-types/shared@3.0.0-nightly-835f0aa1b-250107(transitive)
Updated@react-aria/interactions@3.0.0-nightly-873f6fe9a-250125
Updated@react-stately/selection@3.0.0-nightly-873f6fe9a-250125