Skip to content

Conversation

adamviktora
Copy link
Contributor

Closes #601

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid, two small comments

const treeViewImport = imports.find(
(specifier) => specifier.imported.name === "TreeView"
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some logic so that it only throws this warning in the event that pf-m-selectable would've been applied?

For easy reference that logic was children && (isSelectable || hasCheckbox)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After doing some investigation, we are not able to check it and we will have to throw a warning every time.

The reason is simple: the children and hasCheckbox props depend on the individual TreeViewDataItem objects from data: TreeViewDataItem[] prop of the TreeViewProps.

And since the TreeView may be used like this:

import {options} from "somewhere";
<TreeView data={options} ...

we are not able to trace it and check the condition.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, good point. Since it will just be a warning it's better that we err on the side of showing the warning when it may not be needed than not showing it when it is.

context.report({
node,
message:
"Selectable styling attribute (`pf-m-selectable`) has been removed in TreeView component.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also could we just add a bit to the message here telling consumers what they might have to do because of this change/how it might impact them?

Copy link
Contributor Author

@adamviktora adamviktora Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what the message should say? Even after checking your React PR patternfly/patternfly-react#10101 and the original issue, I have no clue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just let them know that they will need to update any selectors in their code or tests that depends on that classname being there, along with any snapshot tests that include the class.

@adamviktora
Copy link
Contributor Author

adamviktora commented Mar 21, 2024

@wise-king-sullyman I started addressing your comments and then I realized I made a mistake in the component name. The breaking change was on a TreeViewListItem, not TreeView.

TreeViewListItem is not directly exported from @patternfly/react-core, we only use this component internally. Although someone may import it with import { TreeViewListItem } from '@patternfly/react-core/dist/esm/components/TreeView/TreeViewListItem';

Do we still need a codemod just in case someone can import it and use it?

@wise-king-sullyman
Copy link
Collaborator

It's still pretty much on TreeView, just indirectly.

I think a codemod would still be good though since the list item class changes will still potentially impact TreeView users. I would just worry about it in that case though and not worry about someone importing it directly like that.

@adamviktora
Copy link
Contributor Author

Oh, I see, you are right. I was way too stuck in the "fixer" mindset from all the other rules 😃 where we only do changes if the exact component is imported.

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@wise-king-sullyman wise-king-sullyman merged commit a7f1836 into patternfly:main Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TreeView - add warning for removal of selectable styling modifier

3 participants