Compare commits

...
Author SHA1 Message Date
tannerlinsley 4b2d0eb187 v7.0.0-alpha.6 2019-06-20 15:24:02 -06:00
ggascoigneandTanner Linsley 5369051b05 Provide option to toggle sort like V6 (#1370)
V7 adds the option to remove a sort option, so it goes from asc -> desc
-> unset, then repeats.  V6 just went from asc -> desc then repeated.

Personally I much preferred this, I think that there's a case to be made
that this is the more expected behavior.

I'm not sure if this is really the best way to fix this since it adds
yet another api option and I completely understand that that is less
than desirable, but I also would rather add an option than have to
duplicate the whole useSortBy hook.
2019-06-20 12:50:36 -06:00
DomenuchandTanner Linsley 58d38b668b changed applyHook to applyPropHooks inside getRowProps mergeProps fn (#1367) 2019-06-20 12:49:04 -06:00
tannerlinsley 9de149cf3c v7.0.0-alpha.5 2019-06-11 11:41:38 -06:00
tannerlinsley 289dca1caf Merge branch 'master' of https://github.com/react-tools/react-table 2019-06-11 11:41:07 -06:00
HellycatandTanner Linsley c6167566da Fix misspelled in propTypes (#1353) 2019-05-31 07:18:26 -06:00
Dmitrii GaidarjiandTanner Linsley 5b0e68aead Fix defaultSortDesc blocking toggle action (#1341)
* Fix defaultSortDesc blocking toggle action

* Revert "Fix defaultSortDesc blocking toggle action"

This reverts commit 15e05cefd820e3f63e80a8e9d31b9431f295b55a.

* Fix defaultSortDesc blocking toggle action
2019-05-31 07:17:58 -06:00
3 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "7.0.0-alpha.4",
"version": "7.0.0-alpha.6",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
+7 -4
View File
@@ -22,14 +22,15 @@ const propTypes = {
columns: PropTypes.arrayOf(
PropTypes.shape({
sortByFn: PropTypes.func,
efaultSortDesc: PropTypes.bool
defaultSortDesc: PropTypes.bool
})
),
sortByFn: PropTypes.func,
manualSorting: PropTypes.bool,
disableSorting: PropTypes.bool,
defaultSortDesc: PropTypes.bool,
disableMultiSort: PropTypes.bool
disableMultiSort: PropTypes.bool,
disableSortRemove: PropTypes.bool
}
export const useSortBy = props => {
@@ -44,6 +45,7 @@ export const useSortBy = props => {
manualSorting,
disableSorting,
defaultSortDesc,
disableSortRemove,
hooks,
state: [{ sortBy }, setState]
} = props
@@ -82,8 +84,9 @@ export const useSortBy = props => {
if (!multi) {
if (sortBy.length <= 1 && existingSortBy) {
if (existingSortBy.desc) {
action = 'remove'
if ((existingSortBy.desc && !resolvedDefaultSortDesc) ||
(!existingSortBy.desc && resolvedDefaultSortDesc)) {
action = disableSortRemove? 'toggle' : 'remove'
} else {
action = 'toggle'
}
+1 -1
View File
@@ -150,7 +150,7 @@ export const useTable = (props, ...plugins) => {
row.getRowProps = props =>
mergeProps(
{ key: ['row', ...path].join('_') },
applyHooks(api.hooks.getRowProps, row, api),
applyPropHooks(api.hooks.getRowProps, row, api),
props
)