-
Notifications
You must be signed in to change notification settings - Fork 100
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
docs(ui-table): function based examples are added to Table #1663
docs(ui-table): function based examples are added to Table #1663
Conversation
<Table.Cell | ||
key={headerId} | ||
width={headers.find(header => header.id === headerId).width} |
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.
This width props was deleted from the original class based example and missing from the functional too. Is there a reason for that?
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.
According to the docs Table.Cell
doesn't have width
prop and also in console below warning is shown
console.js:53 Warning: [Cell] prop 'width' is not allowed.
That's why I removed the width prop. If it is needed for some kind of a workaround solution I can add it back.
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.
okay, thanks for the clarification
<FormField id="columnTextAlign" label="Set column text-align"> | ||
<Flex margin="0 0 medium"> | ||
{Object.entries(colTextAligns).map(([headerId, textAlign]) => { | ||
return ( |
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.
This whole Formfield is missing from the function-based component.
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.
I just realized that the renderOptions
function in the class-based example has two return statements, with the second one including the FormField. I think we should remove the unreachable return statement completely from the class-based component.
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.
I agree, it should be removed
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.
Done
- ```javascript | ||
const SortableTable = ({ caption, headers, rows }) => { | ||
const initialColWidth = {} | ||
headers.forEach((header) => { | ||
initialColWidth[header.id] = 'start' | ||
}) |
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.
This whole functional example doesn't work, it throws an error: TypeError: Cannot read properties of undefined (reading 'onRequestSort'). Can you please look into this again?
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.
I couldn't reproduce this issue in my local. I can sort the table as expected. Could you provide more context like if there is any like special settings set etc.?
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.
I checked it again, it works now 👍
<Table.Row> | ||
{(headers || []).map(({ id, text, width }) => ( | ||
{headers.map(({ id, text, width }) => ( |
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.
Here there is truthy check in the class-based example "((headers || []).map(...", which is missing from here.
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.
Done
return ( | ||
<Tag | ||
style={rowStyle} | ||
role={isStacked ? 'row' : undefined} |
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.
This role prop is missing from the functional example
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.
Added
.map((child, index) => { | ||
return React.cloneElement(child, { | ||
key: child.props.name, | ||
// used by `CustomTableCell` to render its column title in `stacked` layout |
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.
I think this comment should be in the functional example too.
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.
Added
363ba97
to
b9e3fd3
Compare
b9e3fd3
to
5d16abe
Compare
No description provided.