fix(#3762): AppHeader Slots#3909
Conversation
681a117 to
c525784
Compare
|
Preview links
Built from commit e6c4f3e. Previews are removed automatically when this PR closes. |
524280a to
8685814
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the AppHeader slot APIs and examples to make React/Angular usage more consistent with other controls (adding explicit “banner/phase/navigation/utilities” APIs), and updates docs/examples accordingly while aiming to preserve legacy slot-based usage.
Changes:
- React: adds
banner,phase,navigation, andutilitiesprops toGoabAppHeader. - Angular: adds
banner,phase,navigation, andutilitiestemplate inputs toGoabAppHeader, and introducesGoabAppHeaderMenu. - Docs & PR apps: updates configuration snippets and example pages to use the new APIs, plus adds bug reproduction routes for #3762.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/react-components/src/lib/app-header/app-header.tsx | Adds new slot props and renders them into goa-app-header. |
| libs/angular-components/src/lib/components/index.ts | Re-exports app-header / app-header-menu under new folder names. |
| libs/angular-components/src/lib/components/app-header/app-header.ts | Adds TemplateRef inputs and projects them into named slots. |
| libs/angular-components/src/lib/components/app-header/app-header.spec.ts | Updates spec import path after renaming. |
| libs/angular-components/src/lib/components/app-header-menu/app-header-menu.ts | Adds Angular wrapper for goa-app-header-menu including slotName host binding. |
| libs/angular-components/src/lib/components/app-header-menu/app-header-menu.spec.ts | Updates spec import path and minor formatting. |
| docs/src/data/configurations/app-header.ts | Updates AppHeader code snippets to use new React props / Angular template inputs. |
| docs/src/data/configurations/app-header-menu.ts | Updates AppHeaderMenu snippets (React/Angular/Web Components). |
| docs/src/content/examples/header-with-navigation/react.tsx | Updates docs example to use navigation/utilities props. |
| docs/src/content/examples/header-with-navigation/angular.html | Updates docs example to use Angular template inputs. |
| docs/generated/component-apis/app-header.json | Updates generated API docs for AppHeader slots. |
| apps/prs/react/src/routes/docs/app-header/app-header.tsx | Updates PR app docs route examples to new React props. |
| apps/prs/react/src/routes/bugs/bug3762.tsx | Adds React PR bug route demonstrating new vs legacy slot usage. |
| apps/prs/react/src/app/routes/bugs/bug3762.route.ts | Registers React PR bug route for #3762. |
| apps/prs/angular/src/routes/docs/app-header/app-header.component.html | Updates PR app Angular docs route examples to template inputs. |
| apps/prs/angular/src/routes/bugs/3762/bug3762.route.json | Registers Angular PR bug route metadata for #3762. |
| apps/prs/angular/src/routes/bugs/3762/bug3762.component.ts | Adds Angular PR bug route component shell for #3762. |
| apps/prs/angular/src/routes/bugs/3762/bug3762.component.html | Adds Angular PR bug route template demonstrating new vs legacy slot usage. |
Comments suppressed due to low confidence (3)
libs/angular-components/src/lib/components/app-header/app-header.ts:45
navigationis projected as a single wrapper<div slot="navigation">…</div>.goa-app-headerv2 navigation expects multiple direct slotted items (it countshost.children[slot="navigation"]and styles via::slotted(a)/::slotted(goa-app-header-menu)), so wrapping will break styling and overflow behavior. Prefer slotting each nav item directly (or update the web component to support nested wrappers).
libs/angular-components/src/lib/components/app-header/app-header.ts:49utilitiesis projected as a single wrapper<div slot="utilities">…</div>. Ingoa-app-headerv2, utilities responsiveness depends on counting/measuring direct slotted utility elements (host.childrenwithslot="utilities"); wrapping multiple actions into one element will be treated as a single item and can disable the intended “utilities menu” behavior and::slotted(a)styling.
libs/angular-components/src/lib/components/app-header/app-header.ts:76banner/phase/navigation/utilitiesinputs introduce new rendering paths (NgTemplateOutlet + slot projection), but the existing spec doesn’t assert these slots are rendered correctly. Add Angular unit tests that bind each template input and verify the expected slotted output undergoa-app-header.
8685814 to
dd42741
Compare
|
Copilot Feedback Addressed:
|
66e675b to
3efa868
Compare
|
Updated the PR with the following:
|
eb55151 to
4d77773
Compare
|
I've made the following changes:
|
4d77773 to
7b67b29
Compare
887c958 to
762bac2
Compare
b03ce14 to
501639e
Compare
|
Addressed your feedback @vanessatran-ddi , including:
I did not remove the |
bb0ed36 to
d967608
Compare
|
Updates:
|
| "required": false, | ||
| "default": null, | ||
| "description": "V2 only: Secondary text displayed under the service name." | ||
| "description": "Secondary text displayed under the service name." |
There was a problem hiding this comment.
I run npm run build:prod local, and I see app-header-menu.json on my local has a change,
I don't understand why this PR doesn't commit this app-header-menu.json but I can see the slotName property be removed from preview link: https://govalta.github.io/ui-components/pr-preview/pr-3909/components/app-header/#react
Looks like even we don't commit, the script run magically somewhere? cc @twjeffery or @bdfranck
d967608 to
e6c4f3e
Compare
twjeffery
left a comment
There was a problem hiding this comment.
@willcodeforcoffee the new props are a nice improvement over the raw slot attribute.
One thing I ran into while testing: if the header's content changes after it's first on screen, it breaks. The clearest case is signing in. Signed out shows a "Sign in" button, the person signs in, and you swap in their profile menu. When that swap happens, React goes fully blank (a removeChild error in the console), and Angular doesn't crash but the utilities just disappear, the Sign in goes and the profile never shows.
From what I can tell it's because the slot content gets moved up and the wrapper div removed when the header first loads, so the frameworks lose track of those nodes when they try to change them later. A header that's set up once and never changes is totally fine, which is everything the examples cover today. But anything that swaps header content on sign-in would hit this.
I noticed Copilot suggested putting the slot on each item instead of wrapping them, and you didn't want to go that way at the time. I tried it for this sign-in case though, and it's what stops the crash, the swap works fine and the profile shows up. Maybe worth another look now that we know it can crash? Happy to dig into it together.
Before (the change)
Our AppHeader examples are using a
slotproperty on some of our components, design.alberta.ca/components/app-header#tab-1, specifically, the Header with Navigation example.See:
After (the change)
Several changes have been made to make these controls more consistent with other controls.
banner,phase,navigation, andutilitiesslots.banner,phase,navigation, andutilitiesslots.headertoapp-headerandheader-menutoapp-header-menuBackward compatibility with slots is maintained.
Make sure that you've checked the boxes below before you submit the PR
Steps needed to test
window.innerWidthincreases for the different Headers on the PR page