-
Notifications
You must be signed in to change notification settings - Fork 31
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
Making Group and Summary regular components, only node passed to components #987
Conversation
… means overrides might disappear, which might break Likert)
…w that the node is passed into a component from GenericComponent (and overridden props are not passed along)
… to the component so they can be handled there instead of using a Context (a context did not affect the directRender() check, so GenericComponent also rendered errors, and the <tbody> got children that were not <tr> elements, because GenericComponent wrapped them).
…need for renderLayoutNode(), which was just a component-switcher _outside_ of GenericComponent, so there was no reason a Summary or Group could not just be rendered in the same way as other components.
…irly safely assume that the function will always return an object (otherwise GenericComponent will still refuse to render anything, which we also have unit tests for).
…can render itself in a Summary
…y. It doesn't have to be this complex, as you can't really click a button that does not exist (and is visible), so cypress would fail the click anyway. Focussing it first is also pointless. Simplifying the code, hoping that will avoid sporadic failures where the elements disappear before actions can be performed.
…borked it, but the cypress tests caught that nicely. Passing each prop on its own is cleaner and works better.
…DOM changed at some point here, so the wrapped items were updated and confuses cypress when the button is clicked. This fixes the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As always a lot of great work! 🚀
label={label} | ||
overrides={overrides} | ||
/> | ||
{RenderSummary && component instanceof FormComponent ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just check if RenderSummary is not null. Because RenderSummary is set to null if the component is not an instance of FormComponent at line 116. :D
{RenderSummary && component instanceof FormComponent ? ( | |
{RenderSummary ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, but typescript doesn't agree with that.. 🤷 It complains because it didn't infer that component must be a FormComponent if RenderSummary is set, so the call to component.renderSummaryBoilerplate()
below fails without that check.
Co-authored-by: David Øvrelid <46874830+framitdavid@users.noreply.github.com>
Co-authored-by: David Øvrelid <46874830+framitdavid@users.noreply.github.com>
SonarCloud Quality Gate failed. |
Description
Yet another installment after #976 made
GenericComponent
possible render with just thenode
object as input. This time:node
fromGenericComponent
, meaning this PR takes this concept one step further. Components no longer should require every component property as input when rendering themselves. A lot of tests had to be rewritten to make this work.Group
andSummary
has been promoted (or demoted?) to regular components, which render viaGenericComponent
. No more need for a super-function that decides if a component can be rendered usingGenericComponent
or directly rendered (any component can now ask to be directly rendered).SummaryComponentSwitch
anymore, as every component type can now implement how it is to be rendered in a Summary instead of the Summary component having to know about different component types.Related Issue(s)
Verification/QA
src/layout/layout.d.ts
andlayout.schema.v1.json
, and these are all backwards-compatiblekind/*
label to this PR for proper release notes grouping