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
3 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "7.0.0-alpha.5",
"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",
+4 -2
View File
@@ -29,7 +29,8 @@ const propTypes = {
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
@@ -84,7 +86,7 @@ export const useSortBy = props => {
if (sortBy.length <= 1 && existingSortBy) {
if ((existingSortBy.desc && !resolvedDefaultSortDesc) ||
(!existingSortBy.desc && resolvedDefaultSortDesc)) {
action = 'remove'
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
)