feat(tables): update tables, context selector#3474
Conversation
|
PF4 preview: https://patternfly-org-pr-3474-v4.surge.sh/v4 |
thatblindgeye
left a comment
There was a problem hiding this comment.
In addition to the file comment below:
- Could we update line ~81 of the
sideNavLayout.jsfile fromalignment=...to the new propalign=...? Right now in the surge the group of items that has the version switcher isn't aligned correctly - Should we open a followup issue to add back in the sorting functionality for the CSS table? Not really a blocker to include it in this PR, and also depends if we want to add the sorting back in
I could try to add it back in. when I was playing with it, it didn't feel like the sorting was adding very much. But i think I have a bit more time to take a second stab at it. |
@thatblindgeye @nicolethoen Is it possible to tackle as a follow up since we need this to land to unblock development in React? |
ae8f432 to
4348c8b
Compare
| return icon.Name.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| icon.Contextual_usage?.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| icon.Extra_context?.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| icon.Label?.toLowerCase().includes(searchValue.toLowerCase()) || |
There was a problem hiding this comment.
Suggest including React_name in the search
| icon.Label?.toLowerCase().includes(searchValue.toLowerCase()) || | |
| icon.Label?.toLowerCase().includes(searchValue.toLowerCase()) || | |
| icon.React_name.toLowerCase().includes(searchValue.toLowerCase()) || |
| </Td> | ||
| <Td data-label="Contextual usage"> | ||
| {recommendation.map(rec => { | ||
| return rec.iconUsage |
There was a problem hiding this comment.
We should only display iconUsage for recommended icons (aka 'new' icons), and add block spacing to avoid results with multiple descriptions from running together (see pficon-dragdrop row in PR preview for 3 contextual usages running together)
| return rec.iconUsage | |
| if (rec.iconType === 'new') { | |
| return ( | |
| <div key={`${rec.style}-${rec.iconName}-contextual-usage`}> | |
| {rec.iconUsage} | |
| </div> | |
| ) | |
| } |
| const filteredRows = React.useMemo(() => { | ||
| return recommendationsArray.filter(recommendation => { | ||
| const oldRec = recommendation[0]; | ||
| const newRec = recommendation[1]; | ||
| return oldRec.iconName.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| oldRec.iconUsage.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| oldRec.type.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| newRec.iconName.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| newRec.iconUsage.toLowerCase().includes(searchValue.toLowerCase()) || | ||
| newRec.type.toLowerCase().includes(searchValue.toLowerCase()) | ||
| }); | ||
| } | ||
| }, [searchValue]); |
There was a problem hiding this comment.
This is hard coded to change 2 results (oldRec & newRec), but some rows have up to 5 results (4 old icons, 1 new icon) so suggest refactoring for a more dynamic approach to cover all use cases. Also incorporates a separate recursive function to pull text out from children for the case of Spinner which otherwise was breaking upon search due to passing nested JSX rather than a searchable string to the iconUsage field:
const concatChildText = (children, text = '') => {
React.Children.forEach(children, (child) => {
if (typeof child === 'string') {
text += child;
} else if (React.isValidElement(child)) {
text = concatChildText(child.props.children, text);
}
});
return text;
}
const filteredRows = React.useMemo(() => {
return recommendationsArray.filter(recommendation => (
recommendation.some(rec => {
return Object.values(rec).some(val => {
const cellText = concatChildText(val);
return cellText.toLowerCase().includes(searchValue.toLowerCase());
});
})
))
}, [searchValue]);
Closes: #3469