fix(DataList): Remove redundant while - #3449
Conversation
|
@karelhala This while loop is there to check that the user is intending to select a DataListItem rather than interact with a child component with a different click hander. As long as you have tested that clicking any checkboxes or dropdowns or any other interact-able child components in the dataListItem does not select the row, then the while loop is unnecessary. When it is done building I will test this as well. |
|
PatternFly-React preview: https://patternfly-react-pr-3449.surge.sh |
Well actually that is what should it should be doing. If some element has Nevertheless I understand why it is there, but |
|
@nicolethoen if that is the case, the dev should use |
@karelhala preventing this behavior was an explicit requirement of the enhancement. But I am happy to work with you to find a better way to implement it. I had to consult with a number of react devs to get to this point. So i'd be very open to other ideas.
@Hyperkid123 but it's internal to the DataListItem component - which is designed to only be used in DataList, so I'm not sure what you mean here. |
|
@nicolethoen I don't see any point for a loop like that. Using stopPropagation has been common practice in JS from start and React is no different (it's just a JS library). Here is a quick demo: https://codesandbox.io/s/gifted-monad-q6d9x If there are any composite data-list component they should just kill the event. |
|
@Hyperkid123 |
And this is a problem why? What if the consumer wants to propagate the event? PF should not be some magical thing that will do everything for us. It should be a set of building blocks. Can we get a response from the person who wanted it like this? I understand that this probably was not your decision. |
This discussion is larger, then. The interaction designers decided it was important that stopping the event propagation was not optional and was enforced by the component. Some of the conversation happened offline, but you can see a reference to the debate in the original PR comments. |
|
I am not against the design. I don't mind the catching of the event. I don't like the implementation. Plus not all events are triggered by clicking. @mcarrano using the loop is not safe and using stop propagation on child components/elements will bring more customization and performance increase. |
|
@Hyperkid123 Feel free to propose an alternative code change :) We just cannot remove the functionality all together (without changing the requirements). |
|
For dataList items that is understandable, if I click on kebab the row should not be selected that is true. However if you use button, input, w/e with this component and add onclick function to it the consumer should be responsible for blocking events. I see that the initial comment is from @mcarrano let me elaborate on this. If you add We can't limit consumers in their actions, this is the reason why so many people are unhappy with PF. Whenever they use some component it is usable for simple and straight forward usecase, but once they want to use it for something complex it just won't work or make their work really difficult. I am willing to change this PR to "block" events in DataListAction and DataListControl. |
|
@karelhala @Hyperkid123 @nicolethoen I am not opposed to using the technique suggested here to stop propagation of the event. My only requirements are that it be possible to block an event triggered from a child component (like opening the kabob menu) from selecting a row AND that the example clearly illustrates how to do that. @karelhala I hear your point about giving consumers of PF greater flexibility in coding behaviors related to these components. I think this is a larger conversation to be had about what the appropriate balance is and how to allow that flexibility while driving consistency in user experience between applications. @tlabaj @dgutride any thoughts? |
|
@karelhala @nicolethoen @Hyperkid123 I have an idea to preserve the original intent which was to prevent actionable items like buttons, dropdowns, from selecting a row. Actionable items are wrapped in the |
|
@jschuler yeah, I like that approach. How about we combine what you proposed (adding a prop to ignore clicks on children) and at the same time we hide this while behind same prop. So we give consumers a bit of more flexibility on this issue and expect they know what are doing when adding an element with |
|
I don't really have time to investigate this PR further. Closing for now and I might come to this later. |
There is while that does nothing just stalls the CPU when user clicks on any data list item. This PR removes such while since it's not needed.