-
Notifications
You must be signed in to change notification settings - Fork 993
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
fix: ENG-8176 fallback UI for unknown elements #3892
Open
shubham-builder
wants to merge
20
commits into
BuilderIO:main
Choose a base branch
from
shubham-builder:ENG-8176
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5668180
fix: ENG-8176 fallback UI for unknown elements
03821ed
updated test
68f1408
changeset
c4212f3
updated tests
8d9b0f7
Merge branch 'main' into ENG-8176
shubham-builder 8cdbf90
added test
74966d5
Merge branch 'ENG-8176' of github.com:shubham-builder/builder into EN…
cb92b52
removed only
678608e
Update packages/sdks-tests/src/e2e-tests/dynamic-unknown-element.spec.ts
shubham-builder 5956668
Update .changeset/odd-ducks-joke.md
shubham-builder 4af0c51
updated test
5bc1e62
updated code
84e4c85
removed only
8d87cce
updated test
46e5c4f
removed element codes
33d06cd
removed unused tagName passing to child component
5936cd0
fixed tests
28ceaad
added check
b0cc41a
added separate handling of known and unknown elements
55fec53
renamed test file
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@builder.io/sdk-angular": patch | ||
--- | ||
|
||
Fix: handle the rendering of unknown HTML elements. |
9 changes: 3 additions & 6 deletions
9
packages/sdks-tests/src/e2e-tests/duplicate-attributes.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '../helpers/index.js'; | ||
|
||
test.describe('Unknown Element', () => { | ||
test('unknown element is rendered', async ({ page, sdk }) => { | ||
test.skip(sdk !== 'angular'); | ||
await page.goto('/dynamic-element'); | ||
|
||
const tagNameLocator = await page.locator('test'); | ||
const tagNameId = await tagNameLocator.getAttribute('builder-id'); | ||
|
||
expect(tagNameId).toBe('builder-493100cea9504d56886045462b65b481'); | ||
await expect(tagNameLocator).toHaveAttribute('class','builder-493100cea9504d56886045462b65b481 builder-block'); | ||
await expect(tagNameLocator).toHaveText('testing text'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export const DYNAMIC_ELEMENT ={ | ||
"data": { | ||
"title": "angular-test-1", | ||
"themeId": false, | ||
"blocks": [ | ||
{ | ||
"@type": "@builder.io/sdk:Element", | ||
"@version": 2, | ||
"tagName": "test", | ||
"id": "builder-493100cea9504d56886045462b65b481", | ||
"component": { "name": "Text", "options": { "text": "testing text" } }, | ||
"responsiveStyles": { | ||
"large": { | ||
"display": "flex", | ||
"flexDirection": "column", | ||
"position": "relative", | ||
"flexShrink": "0", | ||
"boxSizing": "border-box", | ||
"marginTop": "20px", | ||
"lineHeight": "normal", | ||
"height": "auto" | ||
} | ||
} | ||
}, | ||
{ | ||
"@type": "@builder.io/sdk:Element", | ||
"@version": 2, | ||
"tagName": "p", | ||
"id": "builder-f6bddd39177d490fb278ad6516fa6a75", | ||
"component": { "name": "Text", "options": { "text": "2222" } }, | ||
"responsiveStyles": { | ||
"large": { | ||
"display": "flex", | ||
"flexDirection": "column", | ||
"position": "relative", | ||
"flexShrink": "0", | ||
"boxSizing": "border-box", | ||
"marginTop": "20px", | ||
"lineHeight": "normal", | ||
"height": "auto" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
with this feature now, we should be able to get rid of manual creation of components and this line here (entire switch case)
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.
This should also fix Angular 16 tests throwing Input annotation errors saying TagName is not defined in other dynamic components
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.
That would mean using the dynamic-unknown-element for all the known elements as well
So in this case even dynamic-p will render as dynamic-unkonwn-element unless it's code is updated accordingly with support of void elements.
Do we want that in same pr or I think we can take it as separate task to eliminate this switch case and use single function to handle known and unknown elements.
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.
IMO we should remove these hard-coded dynamic elements from dynamic renderer and use this
dynamic-unknown-element
to render dynamic elements. We could rename this todynamic-element
also if it makes more sense or even better we could refactor it so that we handle this inside the dynamic renderer itself (because that's the role of dynamic-renderer) but I think for now removing the switch and handling all the elements inside dynamic-element will be nice. What do you think?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.
That totally makes sense