[dev] AB#22227 - Filters Drawer and Filters Rail For Page and Drawer, Checkbox and Toggle added to Filters Drawer#93
Conversation
groberts314
left a comment
There was a problem hiding this comment.
Mostly looking good. I called out a few things here and there, but nothing that rises to the level of a blocker I'd say.
|
|
||
| <Drawer.Content> | ||
| {_.map(rows, (row) => { | ||
| rowKeyNum += 1; |
There was a problem hiding this comment.
How is this any different from simply using the array index as a key? :-)
Not actionable; I'm sure it's just fine as-is. I'm just curious about the thinking here.
There was a problem hiding this comment.
My thinking here is: don't ever use the index even if i know the list isn't going to change its sort order. Use an ID whenever possible and when not, use a global index.
There was a problem hiding this comment.
Okay, so, in your opinion, this is preferred in cases where there is no ID or other "natural" key to help reinforce that one should never use the array key, period? I'll buy that.
There was a problem hiding this comment.
Yep, that's my personal take. Doesn't have to be anyone else's though.
There was a problem hiding this comment.
I understand. It does have the benefit of allowing all developers to look at the same code and always know that "array indexes as keys are an anti-pattern". That's an easier policy to grok than "sometimes using array indexes as keys are okay and other times it's bad; it depends!"
So ... I'm buying what you're selling.
| onKeyDown(event) { | ||
| const { nestedTogglesData, onClick } = this.props; | ||
|
|
||
| if (event.keyCode === 13) { |
There was a problem hiding this comment.
Don't we have a const for this somewhere?
There was a problem hiding this comment.
Not yet. Do we need a const?
There was a problem hiding this comment.
I see this littered all over HC:
const ENTER_KEY_CODE = 13;
class FooComponent extends React.PureComponent {
// ... blah blah blah ...
onKeyDown(event) {
if (event.keyCode === ENTER_KEY_CODE) {
// do whatever it is supposed to do when 'Enter' was hit...
}
}
// ... more blah blah blah ...
}At some point we had discussed moving const ENTER_KEY_CODE = 13; into some shared constants file, exporting it from there and importing it everywhere it is needed, but apparently we never pulled the trigger on that. Is it worth doing something like that in both projects (React-CM-UI and HC), or is that overkill?
There was a problem hiding this comment.
Yeah, you're right, I think it would be better to have a util function to handle the problem instead of a util const. What do you think?
There was a problem hiding this comment.
something like this?
utils/keyEventUtils.js
const ENTER_KEY_CODE = 13;
// ...
export function isEnterKeyEvent(event) {
return _.isObject(event) && event.keyCode === ENTER_KEY_CODE;
}| Page.FiltersRail = PageFiltersRail; | ||
| Page.Grid = PageDataCards; // TODO: Deprecated. Alias name for Page.DataCard. Remove in next major release. | ||
| Page.Table = PageDataGrid; // TODO: Deprecated. Alias name for Page.DataGrid. Remove in next major release. | ||
| Page.Grid = PageDataCards; // TODO: Deprecated. Alias name for Page.DataCard. Remove in a major release. |
There was a problem hiding this comment.
Should it be Page.DataCard (singular) or Page.DataCards (plural)?
There was a problem hiding this comment.
Page/Drawer.DataCards. Plural because there can be more than one. It's my belief that Page/Drawer.DataGrid is plural as well, because "grid" can be referring to one or more.
There was a problem hiding this comment.
Is the actual alias correct then and just the comment is off?
There was a problem hiding this comment.
The comment is off. Sorry. :(
fantaJinMode
left a comment
There was a problem hiding this comment.
Looks good. Just a small change regarding component name
groberts314
left a comment
There was a problem hiding this comment.
I think this is good enough for a ![]()
No unresolved discussion points represent blockers; we can always iteratively improve the codebase.
Features and Fixes in this PR:
New
./src/File Structure Beginnings./src/templates../src/templatesJS/JSX files are Eslint free../docs/package.jsondependenciesanddevDependenciesto./docs/new package.json./docs/FiltersDrawer:
<FiltersDrawer />now.checkboxandtoggleto./docs/modules/drawerFiltersDrawer.js->./docs/tempaltes/drawerFiltersDrawer.jsx../docs/modules/drawerDeprecatedFiltersDrawer.jsContainer
Content