天天看點

關于試圖給新打開的Component第一個focusable元素設定focus的問題My failed attempt

Requirement from https://github.com/SAP/spartacus/issues/9531

Current

While tabbing through the b2b table component, opening up a new section (on the right) is not making the focus to go to the newly opened section, but rather the focus stays where it was (where we pressed enter).

Expected

After opening up a new section, the focus should go to the first element of the section.

關于試圖給新打開的Component第一個focusable元素設定focus的問題My failed attempt

expected behavior:Unit Detail Component(let’s say component B is opened)

The first focusable element in component B, in this case the Edit button, MUST BE FOCUSED automatically.

關于試圖給新打開的Component第一個focusable元素設定focus的問題My failed attempt

My failed attempt

add this line in unit-details.component.html:

關于試圖給新打開的Component第一個focusable元素設定focus的問題My failed attempt

this approach does not work:

in debugging, although this.firstFocusable is successfully parsed to point to a.link.edit.disabled

關于試圖給新打開的Component第一個focusable元素設定focus的問題My failed attempt

Unfortunately at this timeslot, a tag has “disabled” class set because of line 6:

According to this stackoverflow thread, calling focus method on a disabled element will not work:

only till the time when Unit detail page finishes rendering and its data is loaded successfully, and then I could simply call its native focus() function, and this time it works.

關于試圖給新打開的Component第一個focusable元素設定focus的問題My failed attempt