goetzrobin / spartan

Cutting-edge tools powering Angular full-stack development.
https://spartan.ng
MIT License
1.35k stars 143 forks source link

fix(tabs): use inject instead of constructor #353

Closed benjaminforras closed 1 month ago

benjaminforras commented 1 month ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

Which package are you modifying?

What is the current behavior?

Currently the Tabs page is failing to load due to a compilation error.

What is the new behavior?

The Tabs page is loading.

Does this PR introduce a breaking change?

Fixes issue with compiling the brn-paginated-tabs-list component. Also fixes some lint issues/warnings.

benjaminforras commented 1 month ago

There might be cases we you need to extend an another class with this class and using protected makes these easily accessible. I think this is why these were marked as protected originally.

Ajit Panigrahi @.***> (időpont: 2024. aug. 11., V, 16:13) ezt írta:

@.**** commented on this pull request.

In libs/ui/tabs/brain/src/lib/brn-tabs-paginated-list.directive.ts https://github.com/goetzrobin/spartan/pull/353#discussion_r1712995730:

  • protected _elementRef: ElementRef = inject(ElementRef);
  • protected _changeDetectorRef: ChangeDetectorRef = inject(ChangeDetectorRef);

It's not relevant to your actual changes, but these 2 can be marked as private since there's no template to use these in. I'm not sure why it was marked as protected earlier.

— Reply to this email directly, view it on GitHub https://github.com/goetzrobin/spartan/pull/353#pullrequestreview-2231825901, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPCPYB4XIVXNBVKF6H4V3DZQ5WSJAVCNFSM6AAAAABMKH66AKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEMZRHAZDKOJQGE . You are receiving this because you authored the thread.Message ID: @.***>

marcjulian commented 1 month ago

The change looks good to me, tabs page and paginated tabs seem to work again. I guess HlmTabsPaginatedListComponent should have called super(...) in the constructor for correct DI of the extended class BrnTabsPaginatedListDirective. But with inject its cleaner.

marcjulian commented 1 month ago

@goetzrobin the tabs page is currently not accessible because of the injection problem in BrnTabsPaginatedListDirective. This change makes totally sense and the tabs page is again accessible without issues.