@@ -86,6 +86,7 @@ const Table = ({
86
86
// State of dropdown menu
87
87
const [ showPageSizes , setShowPageSizes ] = useState ( false ) ;
88
88
const editTableViewModalRef = useRef < ModalHandle > ( null ) ;
89
+ const selectAllCheckboxRef = useRef < HTMLInputElement > ( null ) ;
89
90
90
91
useEffect ( ( ) => {
91
92
// Function for handling clicks outside of an open dropdown menu
@@ -128,6 +129,8 @@ const Table = ({
128
129
} ;
129
130
130
131
const sortByColumn = ( colName : string ) => {
132
+ // By sorting, any selected item has to be deselected!
133
+ forceDeselectAll ( ) ;
131
134
dispatch ( setSortBy ( colName ) ) ;
132
135
let direction : ReverseOptions = "ASC" ;
133
136
if ( reverse && reverse === "ASC" ) {
@@ -137,6 +140,13 @@ const Table = ({
137
140
dispatch ( updatePages ( ) ) ;
138
141
} ;
139
142
143
+ const forceDeselectAll = ( ) => {
144
+ dispatch ( changeAllSelected ( false ) ) ;
145
+ if ( selectAllCheckboxRef . current ?. checked ) {
146
+ selectAllCheckboxRef . current . checked = false ;
147
+ }
148
+ }
149
+
140
150
const showEditTableViewModal = async ( ) => {
141
151
editTableViewModalRef . current ?. open ( )
142
152
} ;
@@ -186,6 +196,7 @@ const Table = ({
186
196
< th className = "small" >
187
197
{ /*Checkbox to select all rows*/ }
188
198
< input
199
+ ref = { selectAllCheckboxRef }
189
200
type = "checkbox"
190
201
onChange = { ( e ) => onChangeAllSelected ( e ) }
191
202
aria-label = { t ( "EVENTS.EVENTS.TABLE.SELECT_ALL" ) }
0 commit comments