-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/improve sorting ux #1541 #1578
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1578 +/- ##
===========================================
+ Coverage 96.19% 96.26% +0.06%
===========================================
Files 161 161
Lines 6863 6989 +126
Branches 2135 2179 +44
===========================================
+ Hits 6602 6728 +126
Misses 240 240
Partials 21 21
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@kevinphippsstfc do you have any thoughts about the sort icon? |
@@ -233,20 +259,20 @@ const CardView = (props: CardViewProps): React.ReactElement => { | |||
//defaultSort has been provided | |||
React.useEffect(() => { | |||
if (title.defaultSort !== undefined && sort[title.dataKey] === undefined) | |||
onSort(title.dataKey, title.defaultSort, 'replace'); | |||
onSort(title.dataKey, title.defaultSort, 'replace', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment, but since you specified shiftDown?: boolean
as optional, you could leave out explicitly specifying false
here. Would have meant less changes in the tests - but no point removing it now, just an observation
<TableSortLabel | ||
active={true} | ||
direction={sort[s.dataKey]} | ||
// Set tabindex to -1 to prevent button focus | ||
tabIndex={-1} | ||
> | ||
{s.dataKey in sort && sort[s.dataKey]} | ||
</TableSortLabel> | ||
) : shiftDown ? ( | ||
<TableSortLabel | ||
active={true} | ||
direction={sort[s.dataKey]} | ||
// Set tabindex to -1 to prevent button focus | ||
tabIndex={-1} | ||
IconComponent={AddIcon} | ||
> | ||
{s.dataKey in sort && sort[s.dataKey]} | ||
</TableSortLabel> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simply & reduce code repetition here by removing the ternary checks and changing TableSortLabel
to:
<TableSortLabel
active={s.dataKey in sort}
direction={sort[s.dataKey]}
// Set tabindex to -1 to prevent button focus
tabIndex={-1}
IconComponent={!(s.dataKey in sort) && shiftDown ? AddIcon : undefined}
>
{s.dataKey in sort && sort[s.dataKey]}
</TableSortLabel>
dataKey in sort ? ( | ||
<TableSortLabel | ||
className={'tour-dataview-sort'} | ||
active={true} | ||
direction={currSortDirection} | ||
onClick={(event) => | ||
onSort(dataKey, nextSortDirection, 'push', event.shiftKey) | ||
} | ||
> | ||
<Typography noWrap sx={{ fontSize: 'inherit', lineHeight: 'inherit' }}> | ||
{label} | ||
</Typography> | ||
</TableSortLabel> | ||
) : ( | ||
<TableSortLabel | ||
className={'tour-dataview-sort'} | ||
active={true} | ||
direction={'desc'} | ||
onClick={(event) => { | ||
onSort(dataKey, nextSortDirection, 'push', event.shiftKey); | ||
setHover(false); | ||
}} | ||
onMouseEnter={() => setHover(true)} | ||
onMouseLeave={() => setHover(false)} | ||
IconComponent={hover ? ArrowUpwardIcon : shiftDown ? AddIcon : SortIcon} | ||
sx={{ | ||
transition: 'opacity 0.5s', | ||
opacity: hover ? 0.7 : 1, | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, some code repetition here. We can reduce this by only adding the extra props when dataKey in sort
is false, e.g.
<TableSortLabel
className={'tour-dataview-sort'}
active={true}
direction={!(dataKey in sort) ? 'desc' : currSortDirection}
onClick={(event) => {
onSort(dataKey, nextSortDirection, 'push', event.shiftKey);
if (!(dataKey in sort)) setHover(false);
}}
{...(!(dataKey in sort)
? {
onMouseEnter: () => setHover(true),
onMouseLeave: () => setHover(false),
IconComponent: hover
? ArrowUpwardIcon
: shiftDown
? AddIcon
: SortIcon,
sx: {
transition: 'opacity 0.5s',
opacity: hover ? 0.7 : 1,
},
}
: {})}
>
<Typography noWrap sx={{ fontSize: 'inherit', lineHeight: 'inherit' }}>
{label}
</Typography>
</TableSortLabel>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, just some minor code styling comments. I like that pressing shift changes the sort buttons to add buttons to represent the different action possible :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments have been addressed - just want to wait for @kevinphippsstfc to take a look before we merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kevin suggested we add hover tooltips to the sort indicators to be explicit that they're prompting the users to sort :)
The tooltips appearing slow the tests down so that they risk timing out
…/ral-facilities/datagateway into feature/improve-sorting-ux-#1541
tests keep timing out so this might help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and Kevin was happy with the UI & the tooltips are working well
Improved sorting UX
This PR implements improved sorting UX.
Changes/ New features:
Each sortable (but not sorted) column now has an 'SortIcon' icon so users know it is clickable.
When shift key is pressed (for multi sort), all Sort Icons change to Add Icons
Single column sort is now the default
Multi column sort is applied when columns are clicked with shift key down
Sorting in the card view works in a similar way to table view, except it doesn't display 'SortIcon' (please let me know if it should).
Testing instructions
Had to modify multiple existing unit and e2e tests to account for new way of multi column sorting.
Additionally, added tests checking for icon changes.
Agile board tracking
connect to #1541