ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

[Feature Request]: `focus` method of components that use ItemNavigation should focus one of the items

Open dimovpetar opened this issue 6 months ago • 4 comments

Feature Request Description

It would be great if the focus() function could restore focus to the previously focused element, or apply it to the appropriate one, in components that use item navigation.

Since item navigation dynamically manages the tabindex of HTML elements within the component, implementing this behavior would significantly enhance usability.

Similar to the List control in OpenUI5, calling focus() should focus either the first item in the list or the last focused item, if one exists.

You can observe the behavior of the List control here: https://stackblitz.com/edit/vitejs-vite-tj5gsxzc?file=index.html

Expected behavior: When focus() is called on a component with item navigation, it should correctly apply focus to the element that was previously focused.

Components that require attention:

  • [ ] compat/Table
  • [ ] MediaGallery
  • [ ] ProductSwitch
  • [ ] SideNavigation
  • [ ] Timeline
  • [ ] Wizard
  • [ ] AvatarGroup
  • [ ] Breadcrumbs
  • [ ] CalendarLegend
  • [ ] ColorPalette
  • [x] List - https://github.com/SAP/ui5-webcomponents/pull/11486
  • [ ] MenuItem
  • [ ] SegmentedButton
  • [ ] TabContainer
  • [ ] Tokenizer

Proposed Solution

Implement getFocusDomRef as follows:

getFocusDomRef(): HTMLElement | undefined {
	return this._itemNavigation._getCurrentItem();
}

Proposed Alternatives

No response

Organization

SAP

Additional Context

No response

Priority

Low

Privacy Policy

  • [x] I’m not disclosing any internal or sensitive information.

dimovpetar avatar May 08 '25 12:05 dimovpetar

Hello @tsanislavgatev, @MapTo0, @dobrinyonkov, @TeodorTaushanov, @aborjinik,

Please take a look at this feature request.

Regards, Nayden

nnaydenow avatar May 12 '25 08:05 nnaydenow

I believe this is for the compat/Table. New WCT does not use the ItemNavigation but home-made GridWalker. The consecutive focus works for the new WCT already as it should in the specification. Please note that the focus rule for the table is not as mentioned here: if you leave the focus while the focus was on the cell (or maybe in the cell content and using F6 to leave the table) then the next focus call to the table should not focus to the cell that had the focus before but its row.

Any consecutive time, move focus to the row which had the focus before

aborjinik avatar May 12 '25 08:05 aborjinik

I believe this is for the compat/Table. New WCT does not use the ItemNavigation but home-made GridWalker. The consecutive focus works for the new WCT already as it should in the specification. Please note that the focus rule for the table is not as mentioned here: if you leave the focus while the focus was on the cell (or maybe in the cell content and using F6 to leave the table) then the next focus call to the table should not focus to the cell that had the focus before but its row.

Any consecutive time, move focus to the row which had the focus before

Yes, you are right. It's related to the compat table.

nnaydenow avatar May 12 '25 10:05 nnaydenow

Internal Reference: BGSOFUIPIRIN-6862

dobrinyonkov avatar Jun 09 '25 11:06 dobrinyonkov