Comments (4)
Few things that were discussed today (@ekashida and myself):
- How to support regular elements to normalize the tabindex? We have two options: polyfill HTMLElement.prototype.tabindex descriptor, or use the patching mechanism in faux-shadow to do this work. Neither of those is trivial.
- How to support custom elements with tabindex=-1? This use a technique that we discussed in the past: if the user is setting the tabindex to -1, we really set it to 0, and then apply the logic described below to place the focus on the proper next/previous focusable elements as a mechanism to skip the focus of the entire subtree of the custom element because the user wants tabindex -1.
- How to support custom element with tabindex=0? If delegatesFocus flag is off, then just set it to 0, but if that flag is on, then you remove the tabindex entirely. Nice trick right?
- How to implement
activeElement
in a custom element with delegatesFocus on. We need some investigation to see how the spec works, e.g.: what if you have x-foo x-bar and input, composed via shadow boundaries, and the focus in place on the input, and x-foo has delegatesFocus on, but x-bar doesn't. In this case, what is the value ofthis.template.activeElement
in x-foo and x-bar? - How to implement
:focus
selector in CSS (in fallback mode, the focus is never really on the custom element, but on a child of it). We can explore focusin/focusout to see if we can add a html attribute that we can use in our css transformer. - How to know in which direction the user is tabbing when a custom element receive the focus? this is need when the user is intending to set the focus to -1 on the custom element, in which case we set it to 0 to control the navigation and place the focus on the next or previous focusable element. (we might need to listen for keyboard interaction etc, another challenge is when the focus is coming from below, shift-tab, the focused element is the last focusable child of the custom element subtree) .
- How to know what is the previous and next focusable element. I found a weird but apparently effective way to do that by making two queries when detecting that the focus should skip the custom element in a particular direction (from the previous bullet point). One query looking for potential focusable elements from document, and another one looking for potential focusable elements from the custom element. It appears that since the query is the same, the result of the second one should be a "segment" of the previous query. If we can identify that segment, and we know the direction that the user is moving, we can them zip thru the proper segment to find the next or previous focusable element that should receive the focus programmatically.
from lwc.
The missing piece here is the :focus
css rule, that is not implemented yet. Let's keep this open.
from lwc.
I'd like to add a few more things, based on the following example: https://playground.lwcjs.org/projects/8nbbO02BF/4/edit
(Assuming static delegatesFocus = true
)
- programmatically setting
focus
on x-button does not set the focus on the button element as expected. However, settingtabindex=0
on the host, does indeed focus the button inside the shadow - when clicking the
h3
element inside x-button, the host doesn't get the:focus
but I believe this is yet to be implemented, just wanted to make sure we are following the spec here. - When
tabindex=-1
is set on the host, then the button doesn't get focused. I'm unclear on the behavior for this one, however, I'd expect this gets ignored since as a component author, I'm specifying that my component does delegatesFocus and therefore should be respected. I see this as a form of "introspection", it's like styling an internal of my component that the consumer shouldn't have access to.
from lwc.
Referencing a couple of issues I've recently discovered: #1032 and #1031
from lwc.
Related Issues (20)
- [HMR] `swapStyle()` API does not account for stylesheet collisions
- [HMR] `swapStyle()` does not work for `static stylesheets`
- Executing Static Resources within LWC HOT 1
- Inconsistent attribute ordering between static/dynamic nodes
- Lightning-datatable has wrong type of parameters passed to custom type columns through typeAttributes that passsed not with "fieldName" HOT 3
- KOA Server Not Able to Add Routes HOT 2
- Lightning datatable admits only 100 records (or something lower than 150, idk) HOT 2
- Add support for dynamic `<slot>` names HOT 3
- Version mismatch warning should warn for patch version differences as well HOT 1
- `@api` decorated property is not reactive with private class properties HOT 1
- Be homogenous to traverse the parent DOM between shadow dom and `lwc:render-mode="light"` mode HOT 6
- [error] LWR Diagnostic Error: 404: Could not find module entry with specifier "lightning/sldsMediaObject"
- Inherited template not found when using TypeScript and Babel HOT 3
- Rendering component with API version 60 lazily inside an element without `lwc:dom=manual` does not invoke `connectedCallback` or render in dev mode
- Synthetic lifecycle observable changes when slotted into native lifecycle
- Allow ElementInternals/FACE without native custom element lifecycle
- Allow components to opt in to native custom element lifecycle
- SSR hydration mismatch errors in `class` attributes HOT 1
- A synthetic shadow component can observe that its slot container is native shadow
- Hydration validation incorrectly fails for statically optimized content HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lwc.