-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(table): Add interactionMode
property to control focus behavior
#8686
Changes from 9 commits
9c44724
39f5987
64b300c
a23363b
b28fa29
753d75e
1374cd2
29c505c
b3b4835
4287c7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import { | |
import { LocalizedComponent } from "../../utils/locale"; | ||
import { Scale, SelectionMode } from "../interfaces"; | ||
import { focusElementInGroup, FocusElementInGroupDestination } from "../../utils/dom"; | ||
import { RowType, TableRowFocusEvent } from "../table/interfaces"; | ||
import { RowType, TableInteractionMode, TableRowFocusEvent } from "../table/interfaces"; | ||
import { isActivationKey } from "../../utils/key"; | ||
import { | ||
connectInteractive, | ||
|
@@ -51,6 +51,9 @@ export class TableRow implements InteractiveComponent, LocalizedComponent { | |
/** @internal */ | ||
@Prop({ mutable: true }) cellCount: number; | ||
|
||
/** @internal */ | ||
@Prop() interactionMode: TableInteractionMode = "interactive"; | ||
|
||
/** @internal */ | ||
@Prop() lastVisibleRow: boolean; | ||
|
||
|
@@ -91,6 +94,7 @@ export class TableRow implements InteractiveComponent, LocalizedComponent { | |
@Watch("scale") | ||
@Watch("selected") | ||
@Watch("selectedRowCount") | ||
@Watch("interactionMode") | ||
handleCellChanges(): void { | ||
if (this.tableRowEl && this.rowCells.length > 0) { | ||
this.updateCells(); | ||
|
@@ -284,6 +288,7 @@ export class TableRow implements InteractiveComponent, LocalizedComponent { | |
|
||
if (cells.length > 0) { | ||
cells?.forEach((cell: HTMLCalciteTableCellElement | HTMLCalciteTableHeaderElement, index) => { | ||
cell.interactionMode = this.interactionMode; | ||
cell.positionInRow = index + 1; | ||
cell.parentRowType = this.rowType; | ||
cell.parentRowIsSelected = this.selected; | ||
|
@@ -385,7 +390,11 @@ export class TableRow implements InteractiveComponent, LocalizedComponent { | |
aria-rowindex={this.positionAll + 1} | ||
aria-selected={this.selected} | ||
class={{ [CSS.lastVisibleRow]: this.lastVisibleRow }} | ||
onKeyDown={(event) => this.keyDownHandler(event)} | ||
onKeyDown={(event) => { | ||
if (this.interactionMode === "interactive") { | ||
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. Could we push this into the event handler to avoid creating a new anonymous function on each render? 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. Updated and will merge in post-Chromatic run. Thanks for review! |
||
this.keyDownHandler(event); | ||
} | ||
}} | ||
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530) | ||
ref={(el) => (this.tableRowEl = el)} | ||
> | ||
|
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.
Nitpick: should this and related styles reflect the updated name?
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.
Updated to match other css cell modifiers 👍