-
Notifications
You must be signed in to change notification settings - Fork 3
List things related to a resource with a custom display #119
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
base: main
Are you sure you want to change the base?
List things related to a resource with a custom display #119
Conversation
6a40e50
to
72edc1e
Compare
if (templateElement == null) { | ||
this.error = "No template element found" | ||
} else if (templateElement.content.childElementCount != 1) { | ||
this.error = "Template element should only have one child, e.g. li" |
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.
The reason for this is that the component will provide resources to each child based on their index. Compared to #43 (comment) this gets rid of the intermediate pos-resource. However, it will still not be possible to have li nested directly within ul, given that pos-list lies between them.
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.
One option would be to allow pos-list to be used as a customized built-in element, i.e. <ul is="pos-list"></ul>
. I would need to look into whether/how stenciljs supports this.
Update: stenciljs does not support customized built-in elements stenciljs/core#4089 (comment)
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.
What about assigning role="list"?
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.
The issue I had in mind is that the only permitted parents for li are ul and ol (or menu). So if a dashboard user cares about correct HTML then I suppose they could use <div role="listitem" style="display:list-item">
I hadn't thought of that.
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've currently ignored correct HTML for this PR. In storybook I've used bare li
s. Let me know if it's an issue.
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 should care for correct HTML and accessibility. Are you sure it would be invalid? As I understand this answer it would not
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 wasn't aware of that, and indeed I tried the pos-list-composition storybook example in https://websiteaccessibilitychecker.com/checker/index.php and it also passes.
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.
In my understanding pos-list should have role "list" and each child role "listitem" by default without additional effort by the dashboard author. pos-list is a list by definition and the created children are it's items
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.
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 disagree that pos-list
is by definition a list - when it's used to produce inline text, the contents can just be a sequence of static text - they should not necessarily be described to the user as list items.
More importantly, I would argue that a dashboard author should be encouraged to use appropriate semantic HTML elements, and if we default to setting role "list" and child role "listitem", then this will clash with any use of ul
and li
- we end up with nested listitems.
That said, the composition storybook example neglected to include ul
, and I have now fixed that.
The current code (without aria roles) produces:
Code with aria roles:
const elems = this.items.map(it => (
<pos-resource role="listitem" uri={it} lazy={!this.fetch} innerHTML={this.templateString} about={it}></pos-resource>
));
return this.items.length > 0 ? <Host role="list">{elems}</Host> : null;
d8624cc
to
ffc74ab
Compare
I've marked as ready for review because I'm not sure what e2e test should be included (is the integration test enough?), and I think we can maybe descope and implement rev in a separate PR - this one is probably complex enough as it is? |
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.
Good work so far! I have several comments and questions, but many of them are minor, I think this goes into a good direction.
You don't need to bother with this in the PR, I will do this after merging before releasing a new version |
I am having an issue using this within another stencil component. If I paste an example directly in index.html it works, but the same example fails when I e.g. use it in pos-app-browser (just replacecing the regular pos-app content with the pos-list example). In the latter case it fails, because it does not recognize the template child (childElementCount == 0). Don't know why yet. |
It seems to be related to what is described here: https://stackoverflow.com/a/70778523 If I pass the content to |
I managed to show my bookmarks using
What is unfortunately still not possible with PodOS is actually linking to the value because I cannot use |
That's frustrating. Is that ok as a solution, or would you like to explore an approach that doesn't use the template tag? I would expect that stencil components would very rarely use pos-list - given they are written in JS they can just use Thing's methods directly and create their own list. |
Nah, I think template is the right approach, is just weired with stencil, I guess we can live with that.
Yes indeed, though I think the issue is not only with stencil but with everything that creates template programmatically, e.g. also with React and other frameworks ( |
1b4d7fb
to
c8e48d1
Compare
With the switch to I've run into two problems: I can't get pos-resource to not fetch when testing, and even when it does fetch, Storybook seems to work fine. I'm guessing I've made a mistake in mocking, but maybe it's in how I call On my system I also get warnings:
Edit: I've pushed an extra commit that implements the fetch attribute + unit tests - but this doesn't address the issue in this integration test |
cdee3bc
to
a71d7ed
Compare
elements/src/components/pos-list/pos-list.integration-fetch.spec.tsx
Outdated
Show resolved
Hide resolved
elements/src/components/pos-list/pos-list.integration-fetch.spec.tsx
Outdated
Show resolved
Hide resolved
a71d7ed
to
96a36ef
Compare
Partly addresses #43
end-to-end testintegration testarchitectural decisions are documented as an ADRKeep a Changelog
This PR descoped to exclude rev, given this will involve changes very similar to rel. Covering rev in a separate PR will hopefully make both PRs easier to review.