-
Notifications
You must be signed in to change notification settings - Fork 77
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
[calcite-table,calcite-list] Refactor component to improve compatibility with lit-html #10495
Comments
#6646 will provide imperative rendering, but I know there is value for a lot of our "dev summit users" / simple use cases to stand up a static table declaratively. If that can be preserved in some way, that would be nice for those cases - alongside the more advanced functionality of course. |
Agree. More research needs to be done, but it appears that the required changes would be done inside the calcite-table code, rather than affecting outside usage. e.g. if it worked in Stencil, it should work in Lit. The only thing that changed is the rendering engine used by calcite-table. |
Is this an issue with calcite-list? It places divs around |
You are correct, that appears to be the case. I did not realize calcite-list was using a table underneath. |
Is this really the case? Wouldn't this be occurring now with these components? This seems like some kind of lit thing not a browser thing. Reading the discussion it sounds like it is a lit thing that its doing because of web spec rules. So its likely something we should fix but it does complicate the conversion to lit. |
I think it may be more than just converting to a div with a role. The colSpan/rowSpan styling might be challenging here. I'd also be concerned with how this affects a11y. If a11y does have an issue with a component between a tr/td then maybe its worth it. Otherwise its a lot to work around. |
I tried the role approach and pushed an example to Edit - oops, of course this is the Stencil version, so you'd need to run the codemod on that branch to see the "true" result I suppose. |
@maxpatiiuk does it also have an issue with |
I do not know. I opened this issue so that someone from the Calcite team could do the research about the exact cause of the problem and the possible solutions.
The main difference is how functional components are parsed & rendered:
|
I have a Lumina branch in a PR - #10482 - feel free to experiment on top of it: But you can also create a small lit app (not even lumina) and play around with how it renders a table - see for example this Lit playground "Code sample" |
Lit also has static templates where you can create template from dynamic parts - https://lit.dev/docs/templates/expressions/#static-expressions You could have renderTHead return an HTML string, that is inlined inside the render() method's template. |
I think this is the issue but this wouldn't work since the table rows/cells are slotted in, so combining them with the table is not a viable option.
This is also an issue since HTML table requires certain direct children. However, stencil doesn't stop you from doing this and it doesn't seem like screen readers care if the HTML isn't valid. It seems like lit does stop you potentially because of the HTML template being used. The solution seems to be to use aria roles for our use cases. |
I checked out the Lumina branch - it seems like the Table renders correctly in some cases (there are some styling and keyboard navigation things here and there, but the structure / layout is accurate). However the cases that appear broken (as shown in screenshot in original post) - we are programmatically rendering additional cells on behalf of the user - this occurs for |
I have a PR open to fix the list component. We may need to identify other components that may be affected with This is one of those quirks with web components where the parent/child can't be separated by a shadow DOM. |
I think the following components will need updating as well:
|
**Related Issue:** #10495 ## Summary - use aria attributes and role instead of semantic elements - This is because table elements need to have their child elements as direct children. - Visual changes are due to not using `td` elements anymore which shifts `1px` padding. Seems ok to me 👍 Probably shouldn't have been there. Was coming from default browser td styles.
@jcfranco do we want to update this issue to include combobox and menu? I think those are the only ones using |
It might not be necessary in menu/combobox. All menu E2E tests are passing on the Lumina branch without refactoring render(). Some combobox tests are failing but the error messages don't look related to this. On the other hand, List and Table tests are failing due to html elements being moved out. |
Ok maybe tables are the only ones with immediate issues. We should have a followup issue to refactor the |
List PR has been installed so it should be good now. |
Make minor adjustments to Calcite code to have post-migration tests pass. Changes that need to be done post-migration are encoded in the following codemod files in the arcgis-web-components repository: - /packages/support-packages/stencil-to-lit/src/code/fileSpecific.ts - /packages/support-packages/stencil-to-lit/src/component/fileSpecific.ts At this point, I am finishing up the failing tests in the S components and will be pretty much done with all A-S component (with exception of #10394 and #10495)
**Related Issue:** #10310, #10481, #10399, #10405, #10491, #10434, #10495, #9260 ## Noteworthy changes * components are now Lit-based * removed `@storybook/test` and `@storybook/addon-interactions` as these were not being actively used * React deps bumped to v18 * Added default `scale` value to: * `action-bar` * `action-group` * `action-menu` * `action-pad` * Path of extras will change to the following: * `/dist/extras/vscode-data.json` ➡️ `/dist/docs/vscode.html-custom-data.json` * backwards-compatible version is preserved to not break Intellisense [described in the doc](https://developers.arcgis.com/calcite-design-system/resources/frameworks/#visual-studio-intellisense) * `/dist/extras/docs-json.json` ➡️ `/dist/docs/docs.json` (internal) * `/dist/extras/translations-json.json` ➡️ `/dist/docs/translations.json` (internal) * `/dist/extras/docs-json.d.ts` ❌ (removed, internal) BREAKING CHANGE: * for a consistent development experience, components now convert `null` to `undefined`, so developers will need to update code with strict null checks * removed the following `@esri/eslint-plugin-calcite-components` rules as they are no longer valid: * `ban-props-on-host` * `enforce-ref-last-prop` * `require-event-emitter-type` --------- Co-authored-by: JC Franco <[email protected]> Co-authored-by: Ben Elan <[email protected]> Co-authored-by: Calcite Admin <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Installed and assigned for verification. |
🍡 Verified |
Description
Post-codemod, most Calcite components work with no or minimal changes.
However,
<calcite-table>
and<calcite-list>
may require some changes because of the way lit-html works.lit-html converts each template to a
<template>
element behind the scenes. That means each template needs to be standalone piece of valid HTML.That is causing issues in
<calcite-table>
- since the table is rendered in pieces, some templates are not valid standalone (tables have strict rules about what elements can be inside of them), and so the browser moves the "invalid" elements out of the table.Similar issues are present in
<calcite-list>
since it's rendered as a table underneath.Code sample (take a look in devtools at what does the rendered html look like)
The solution proposed by Lit is to use div[role="cell"] and etc instead of td inside the calcite-table components.
then with css apply display:table-cell;
Example: https://lit.dev/playground/#gist=0b495facaf08c1f990e9879f54405fc8
The other options might be to rendering more parts of the table as a single lit-html template, or doing imperative rendering in table components.
As far as I am aware, other component are not subject to this issue - it's just table that has these restrictions.
Proposed Advantages
calcite-table needs to be refactored a bit to render correctly in lit-html.
Until then, the browser may move what it sees as "HTML element with incorrect placement" out of the table, breaking the layout:
Which Component
calcite-table
Relevant Info
No response
Calcite package
The text was updated successfully, but these errors were encountered: