@@ -56,6 +56,11 @@ const metadata = {
56
56
* @public
57
57
*/
58
58
class TableRow extends UI5Element {
59
+ constructor ( ) {
60
+ super ( ) ;
61
+ this . fnOnCellClick = this . _oncellclick . bind ( this ) ;
62
+ }
63
+
59
64
static get metadata ( ) {
60
65
return metadata ;
61
66
}
@@ -72,6 +77,28 @@ class TableRow extends UI5Element {
72
77
return TableRowTemplate ;
73
78
}
74
79
80
+ _onfocusin ( event , forceSelfFocus = false ) {
81
+ if ( forceSelfFocus || this . _getActiveElementTagName ( ) === "ui5-table-cell" ) {
82
+ this . getDomRef ( ) . focus ( ) ;
83
+ }
84
+
85
+ this . fireEvent ( "_focused" , event ) ;
86
+ }
87
+
88
+ _oncellclick ( event ) {
89
+ if ( this . _getActiveElementTagName ( ) === "body" ) {
90
+ // If the user clickes on non-focusable element within the ui5-table-cell,
91
+ // the focus goes to the body, se we have to bring it back to the row.
92
+ // If the user clicks on input, button or similar clickable element,
93
+ // the focus remains on that element.
94
+ this . _onfocusin ( event , true /* force row focus */ ) ;
95
+ }
96
+ }
97
+
98
+ _getActiveElementTagName ( ) {
99
+ return document . activeElement . localName . toLocaleLowerCase ( ) ;
100
+ }
101
+
75
102
onBeforeRendering ( ) {
76
103
this . visibleCells = [ ] ;
77
104
this . popinCells = [ ] ;
@@ -128,10 +155,6 @@ class TableRow extends UI5Element {
128
155
get visibleCellsCount ( ) {
129
156
return this . visibleCells . length ;
130
157
}
131
-
132
- onfocusin ( event ) {
133
- this . fireEvent ( "_focused" , event ) ;
134
- }
135
158
}
136
159
137
160
TableRow . define ( ) ;
0 commit comments