-
Notifications
You must be signed in to change notification settings - Fork 1
LPD-24670 WIP. #5110
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
LPD-24670 WIP. #5110
Conversation
… case of list we need to mutate item as ClayList.Item does not take any prop we can remap.
CI is automatically triggering the following test suites:
|
Test suite sf has been triggered on http://test-1-32 |
✔️ ci:test:sf - 1 out of 1 jobs passed in 3 minutesRan com.liferay.source.formatter at released version 1.0.1543. Click here for more details.Base Branch:Branch Name: master Sender Branch:Branch Name: LPD-24670 1 Successful Jobs:For more details click here. |
Jenkins Build:test-portal-source-format#10886 Jenkins Report:jenkins-report.html Jenkins Suite:sf Pull Request:liferay-frontend#5110 Testray Routine:EE Pull Request Testray Build ID: 334418936 Testray Importer:test-portal-source-format#10886 |
…ormer to the parent component. This assumes it makes no sense to manage <ClayList.Item> props directly
@markocikos I've added an extra commit that solves the item mutation issue, but changes a bit the application of |
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.
@dsanz @chestofwonders please see comment inline
return { | ||
...props, // we need to avoid item mutation | ||
item: { | ||
...item, | ||
symbol: 'warning', | ||
tooltip: 'perico' | ||
} | ||
} |
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.
My first feeling about this was that it wasn't right, because API was intended to modify props of component implementing the item, <ClayList.Item>
. It does make sense to shift target of customization to <ListItem>
, our own wrapper of the component. It makes customization of our implementation more flexible. But. it's a tradeoff. We lose future-proof aspect of the solution, where devs would automatically be able to modify future props of <ClayList.Item>
. It might make sense to add a prop specifically for that purpose. Something like
const props = {
className,
clayListItemProps, // new prop
item,
items,
onItemSelectionChange,
ref:dropRef,
schema,
};
<ListItem
{...props}
{...(activeView.setItemComponentProps?.({item, props}) ?? {})}
that ends up in
<ClayList.Item
className={classNames(className, {
active: selectedItemsValue?.includes(itemId),
})}
flex
{...clayListItemProps}
>
In general, mutating item is not good practice, but I think it's acceptable this close to leaf usage.
What do you think?
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.
Doing this shift makes item not mutated indeed.
Note how first commit does item.foo = bar
whereas second one just provides a different item. So no internal FDS state is mutated.
It's true that we are changing the item we pass to the child component. I believe there's a slight difference between this and mutating the item.
And yes, what you say makes sense to me, we need to open the possibility to drill down props in the "real" target component here. @chestofwonders pls add this to #5122 so that devs have access to the underlying <ClayList.Item>
so that we get the best of both worlds
Thank you @markocikos !
Pls see #5122 |
Context: https://liferay.atlassian.net/browse/LPD-24670
Goal is to check selected item has no visualization modes, to render it differently
How it looks like

With this commit, a Data Set with no visualization mode appears with a warning icon:
Problem: in the case of list visualization, we need to mutate item as ClayList.Item does not take any prop we can remap.
Proposal to handle this case for list views, which we can use in all views:
setItemProps
function that returns a modified item to be consumed by views.List
):This came from a quick peer session with @chestofwonders
cc @markocikos as you designed this solution, pls chime in and share yout thougths