-
Notifications
You must be signed in to change notification settings - Fork 275
fix(ui5-table): fix row navigation and focus handling #876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1d0950b
fix(ui5-table): row navigation and focus handling
ilhan007 a1c208a
Merge branch 'master' into fix-tabble-navigation
ilhan007 36c073f
rems instead of px
ilhan007 540fe24
remove pointer-events: none
ilhan007 ea4b691
attach for cell click in template
ilhan007 1d323a5
include column header in row navigation
ilhan007 721c492
fix js error when column header is not yet rendered
ilhan007 5b1ba0d
simplify if condition
ilhan007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<td> | ||
<td tabindex="-1"> | ||
<slot></slot> | ||
</td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,11 @@ const metadata = { | |
* @public | ||
*/ | ||
class TableRow extends UI5Element { | ||
constructor() { | ||
super(); | ||
this.fnOnCellClick = this._oncellclick.bind(this); | ||
} | ||
|
||
static get metadata() { | ||
return metadata; | ||
} | ||
|
@@ -72,6 +77,28 @@ class TableRow extends UI5Element { | |
return TableRowTemplate; | ||
} | ||
|
||
_onfocusin(event, forceSelfFocus = false) { | ||
if (forceSelfFocus || this._getActiveElementTagName() === "ui5-table-cell") { | ||
this.getDomRef().focus(); | ||
} | ||
|
||
this.fireEvent("_focused", event); | ||
} | ||
|
||
_oncellclick(event) { | ||
if (this._getActiveElementTagName() === "body") { | ||
// If the user clickes on non-focusable element within the ui5-table-cell, | ||
// the focus goes to the body, se we have to bring it back to the row. | ||
// If the uset clicks on input, button or similar clickable element, | ||
// the focus remains on that element. | ||
this._onfocusin(event, true /* force row focus */); | ||
} | ||
} | ||
|
||
_getActiveElementTagName() { | ||
return document.activeElement.localName.toLocaleLowerCase(); | ||
} | ||
|
||
onBeforeRendering() { | ||
this.visibleCells = []; | ||
this.popinCells = []; | ||
|
@@ -80,6 +107,11 @@ class TableRow extends UI5Element { | |
return; | ||
} | ||
|
||
this.cells.forEach(cell => { | ||
cell.removeEventListener("click", this.fnOnCellClick); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you better fire some event from the cell and rely on bubbling so you can catch it in the Row There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
cell.addEventListener("click", this.fnOnCellClick); | ||
}); | ||
|
||
this._columnsInfo.forEach((info, index) => { | ||
const cell = this.cells[index]; | ||
|
||
|
@@ -128,10 +160,6 @@ class TableRow extends UI5Element { | |
get visibleCellsCount() { | ||
return this.visibleCells.length; | ||
} | ||
|
||
onfocusin(event) { | ||
this.fireEvent("_focused", event); | ||
} | ||
} | ||
|
||
TableRow.define(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
:root {} | ||
:root { | ||
--ui5_table_header_row_outline_width: 1px; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:root { | ||
--ui5_table_row_outline_width: 1px; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import "../base/TableRow-parameters.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
@import "../base/Table-parameters.css"; | ||
@import "../base/Table-parameters.css"; | ||
|
||
:root { | ||
--ui5_table_header_row_outline_width: 0.125rem; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/main/src/themes/sap_belize_hcb/TableRow-parameters.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import "../base/TableRow-parameters.css"; | ||
|
||
:root { | ||
--ui5_table_row_outline_width: 0.125rem; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import "../base/TableRow-parameters.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wish we make this part of the item navigation but its fine for now
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.