From ae9745dc9e140a104de427c49ee7734baacb94f5 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Mon, 23 May 2022 14:39:03 +0100 Subject: [PATCH] Add onKeyPress event handler to capture e.shiftKey, unavailable in onChange (#3768) --- packages/@uppy/provider-views/src/Browser.jsx | 3 +++ .../@uppy/provider-views/src/Item/components/GridLi.jsx | 2 ++ .../@uppy/provider-views/src/Item/components/ListLi.jsx | 2 ++ .../provider-views/src/ProviderView/ProviderView.jsx | 3 ++- packages/@uppy/provider-views/src/SharedHandler.js | 8 ++++++-- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/@uppy/provider-views/src/Browser.jsx b/packages/@uppy/provider-views/src/Browser.jsx index 65db065332..72d0a03a97 100644 --- a/packages/@uppy/provider-views/src/Browser.jsx +++ b/packages/@uppy/provider-views/src/Browser.jsx @@ -21,6 +21,7 @@ function Browser (props) { showBreadcrumbs, isChecked, toggleCheckbox, + recordShiftKeyPress, handleScroll, showTitles, i18n, @@ -91,6 +92,7 @@ function Browser (props) { getItemIcon: () => folder.icon, isChecked: isChecked(folder), toggleCheckbox: (event) => toggleCheckbox(event, folder), + recordShiftKeyPress, type: 'folder', isDisabled: isChecked(folder)?.loading, isCheckboxDisabled: folder.id === VIRTUAL_SHARED_DIR, @@ -111,6 +113,7 @@ function Browser (props) { getItemIcon: () => file.icon, isChecked: isChecked(file), toggleCheckbox: (event) => toggleCheckbox(event, file), + recordShiftKeyPress, columns, showTitles, viewType, diff --git a/packages/@uppy/provider-views/src/Item/components/GridLi.jsx b/packages/@uppy/provider-views/src/Item/components/GridLi.jsx index e4f7bdd480..395600255a 100644 --- a/packages/@uppy/provider-views/src/Item/components/GridLi.jsx +++ b/packages/@uppy/provider-views/src/Item/components/GridLi.jsx @@ -10,6 +10,7 @@ function GridListItem (props) { itemIconEl, showTitles, toggleCheckbox, + recordShiftKeyPress, id, children, } = props @@ -25,6 +26,7 @@ function GridListItem (props) { isChecked ? 'uppy-ProviderBrowserItem-checkbox--is-checked' : '' } uppy-ProviderBrowserItem-checkbox--grid`} onChange={toggleCheckbox} + onKeyDown={recordShiftKeyPress} name="listitem" id={id} checked={isChecked} diff --git a/packages/@uppy/provider-views/src/Item/components/ListLi.jsx b/packages/@uppy/provider-views/src/Item/components/ListLi.jsx index 0e132202b6..c88726f1b7 100644 --- a/packages/@uppy/provider-views/src/Item/components/ListLi.jsx +++ b/packages/@uppy/provider-views/src/Item/components/ListLi.jsx @@ -15,6 +15,7 @@ function ListItem (props) { isCheckboxDisabled, isChecked, toggleCheckbox, + recordShiftKeyPress, type, id, itemIconEl, @@ -34,6 +35,7 @@ function ListItem (props) { type="checkbox" className={`uppy-u-reset uppy-ProviderBrowserItem-checkbox ${isChecked ? 'uppy-ProviderBrowserItem-checkbox--is-checked' : ''}`} onChange={toggleCheckbox} + onKeyDown={recordShiftKeyPress} // for the