79673144

Date: 2025-06-20 09:34:37
Score: 1.5
Natty:
Report link

As already mentioned by @bassxzero it is not recommended on component-level.

But I also understand why you like the idea. It looks kind of readable and cool. However, I think the mentioned "prop-drilling" is necessary here, makes the behavior much more clear and won't be too bad.

For instance you could have a component that contains itself a set of focusable elements. I think in those cases you want the component to decide what should be focused.

Here is an example.


If all of that didn't convince you, you could consider to write a little more logic into your directive that finds the first element in the given element tree that is of type "input", "select" etc. or has the "tabIndex" property set and its value is >= 0.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • User mentioned (1): @bassxzero
  • Low reputation (0.5):
Posted by: Viktor Luft