Skip to content

Update keyboard navigation topic for React 19 #1515

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

Open
wants to merge 2 commits into
base: vnext
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions doc/en/components/grids/_shared/keyboard-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,32 +197,32 @@ igRegisterScript("WebGridCustomKBNav", (evtArgs) => {
```

```tsx
<{ComponentSelector} id="grid1" primaryKey="ProductID" gridKeydown={customKeydown}>
<{ComponentSelector} id="grid1" primaryKey="ProductID" onGridKeydown={customKeydown}>
</{ComponentSelector}>
```

<!-- WebComponents -->
```ts
constructor() {
var grid = this.grid = document.getElementById('grid') as {ComponentName}Component;
const grid = this.grid = document.getElementById('grid1') as {ComponentName}Component;
grid.data = this.data
grid.addEventListener("gridKeydown", this.customKeydown);
grid.addEventListener("onGridKeydown", this.customKeydown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event for WC is still gridKeydown

}
```
<!-- end: WebComponents -->

```typescript
function customKeydown(s: IgrGridBaseDirective, e: IgrGridKeydownEventArgs) {
const detail = e.detail
const target= detail.target;
const evt = detail.event;
const type = detail.targetType;
const customKeydown = (eventArgs: IgrGridKeydownEventArgs) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this snippet is for React only since in WC the components are classes.

const args = eventArgs.detail;
const target= args.target;
const evt = args.event;
const type = args.targetType;

if (type === GridKeydownTargetType.DataCell && target.editMode && evt.key.toLowerCase() === 'tab') {
if (type === 'dataCell' && target.editMode && evt.key.toLowerCase() === 'tab') {
// 1. USER INPUT VALIDATION ON TAB

}
if (type === GridKeydownTargetType.DataCell && evt.key.toLowerCase() === 'enter') {
if (type === 'dataCell' && evt.key.toLowerCase() === 'enter') {
// 2. CUSTOM NAVIGATION ON ENTER KEY PRESS

}
}
```
Expand Down