spartan icon indicating copy to clipboard operation
spartan copied to clipboard

fix(tabs): use inject instead of constructor

Open benjaminforras opened this issue 1 year ago • 1 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [ ] The commit message follows our guidelines: https://github.com/goetzrobin/spartan/blob/main/CONTRIBUTING.md#-commit-message-guidelines
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [x] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Documentation content changes
  • [ ] Other... Please describe:

Which package are you modifying?

  • [ ] accordion
  • [ ] alert
  • [ ] alert-dialog
  • [ ] aspect-ratio
  • [ ] avatar
  • [ ] badge
  • [ ] button
  • [ ] calendar
  • [ ] card
  • [ ] checkbox
  • [ ] collapsible
  • [ ] combobox
  • [ ] command
  • [ ] context-menu
  • [ ] data-table
  • [ ] date-picker
  • [ ] dialog
  • [ ] dropdown-menu
  • [ ] hover-card
  • [ ] icon
  • [ ] input
  • [ ] label
  • [ ] menubar
  • [ ] navigation-menu
  • [ ] pagination
  • [ ] popover
  • [ ] progress
  • [ ] radio-group
  • [ ] scroll-area
  • [ ] select
  • [ ] separator
  • [ ] sheet
  • [ ] skeleton
  • [ ] slider
  • [ ] sonner
  • [ ] spinner
  • [ ] switch
  • [ ] table
  • [x] tabs
  • [ ] textarea
  • [ ] toast
  • [ ] toggle
  • [ ] tooltip
  • [ ] typography

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?

  • [ ] Yes
  • [x] No

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

benjaminforras avatar Aug 11 '24 00:08 benjaminforras

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<HTMLElement> = 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: @.***>

benjaminforras avatar Aug 11 '24 14:08 benjaminforras

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 avatar Aug 12 '24 09:08 marcjulian

@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.

marcjulian avatar Aug 26 '24 10:08 marcjulian