Skip to content
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

tree: importing MatIconModule and MatButtonModule is necessary #20239

Closed
tom-richter opened this issue Jul 30, 2020 · 6 comments
Closed

tree: importing MatIconModule and MatButtonModule is necessary #20239

tom-richter opened this issue Jul 30, 2020 · 6 comments
Assignees
Labels
area: material/tree docs This issue is related to documentation good first issue This issue is a good place to start for first time contributors to the project help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@tom-richter
Copy link

It would be helpful to mention in the API reference for Angular Material tree that besides the MatTreeModule also MatIconModule and MatButtonModule must be imported into the app.module.ts.
(eg. when you use a "Tree with flat nodes")

import {MatButtonModule} from '@angular/material/button';
import {MatIconModule} from '@angular/material/icon';
import {MatTreeModule} from '@angular/material/tree';
@tom-richter tom-richter changed the title API reference for Angular Material tree - MatIconModule and MatButtonModule API reference for Angular Material tree - MatIconModule and MatButtonModule also necessary Jul 30, 2020
@Splaktar Splaktar changed the title API reference for Angular Material tree - MatIconModule and MatButtonModule also necessary tree: importing MatIconModule and MatButtonModule is necessary Aug 7, 2020
@Splaktar
Copy link
Member

Splaktar commented Aug 7, 2020

As this is docs' content, I'll move this over the the Components repo. This repo is only for docs infrastructure.

@Splaktar Splaktar transferred this issue from angular/material.angular.io Aug 7, 2020
@Splaktar Splaktar added area: material/tree needs triage This issue needs to be triaged by the team labels Aug 7, 2020
@crisbeto
Copy link
Member

crisbeto commented Aug 9, 2020

For what it's worth, the icon and button modules aren't mandatory for the tree to work, but they are needed if you wanted to replicate the demo from the docs. We should still mention it somewhere in the docs.

@crisbeto crisbeto added docs This issue is related to documentation good first issue This issue is a good place to start for first time contributors to the project help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Aug 9, 2020
@0x1211
Copy link

0x1211 commented Aug 26, 2020

@crisbeto Considering most of the components usage examples are using mat-icon-button directive or <mat-icon> selector would this still be relevant (another example being the Menu component) ? Should some kind of global mention to these necessary imports be considered in the documentation then ?

@tom-richter
Copy link
Author

Yes, for me as an Angular Material beginner I copied the code from the documentation and spent half an hour debugging until I found out why the material tree style is not applied. There is no descriptive error message. The tree just looks strange like in this issue:
https://stackoverflow.com/questions/57527296/material-tree-style-not-being-applied/63174068#63174068

@zarend zarend self-assigned this May 26, 2021
@zarend
Copy link
Contributor

zarend commented May 26, 2021

Closing this because importing the mat button and icon modules are not required for the tree to work. In the case of the flat tree example, we are directing using MatButton, and we directly use MatIcon inside the button. It's the direct usages that require the MatIconModule and the MatButtonModule. In other cases where a component is used inside another (like MatTreeNode), the dependencies are already imported in the appropriate NgModule.

@zarend zarend closed this as completed May 26, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/tree docs This issue is related to documentation good first issue This issue is a good place to start for first time contributors to the project help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

5 participants