Skip to content

Refactor pointer events handling when resizing columns - #2595

Merged
nstepien merged 5 commits into
mainfrom
pointer
Aug 20, 2021
Merged

nstepien merged 5 commits into
mainfrom
pointer

Conversation

@nstepien

@nstepien nstepien commented Aug 20, 2021 •

Copy link
Copy Markdown
Collaborator

https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
https://developer.mozilla.org/en-US/docs/Web/API/Element/releasePointerCapture
With this API, we shouldn't need any special handling when the pointer is outside the target.
Except iframes...
I believe we also don't need to check for multi-touch, not 100% sure, can't really test.
We should try this with the drag handle as well.

@nstepien nstepien self-assigned this Aug 20, 2021
@codecov

codecov Bot commented Aug 20, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #2595 (28a659a) into main (84e9adb) will decrease coverage by 0.05%.
The diff coverage is 82.60%.

❗ Current head 28a659a differs from pull request most recent head d9778c7. Consider uploading reports for the commit d9778c7 to get more accurate results

@@            Coverage Diff             @@
##             main    #2595      +/-   ##
==========================================
- Coverage   90.54%   90.48%   -0.06%     
==========================================
  Files          38       38              
  Lines        3681     3690       +9     
  Branches      487      485       -2     
==========================================
+ Hits         3333     3339       +6     
- Misses        348      351       +3     
Impacted Files Coverage Δ
src/HeaderCell.tsx 92.00% <81.81%> (-1.34%) ⬇️
src/HeaderRow.tsx 97.61% <100.00%> (-0.03%) ⬇️

@nstepien
nstepien marked this pull request as ready for review August 20, 2021 17:11
@nstepien
nstepien requested a review from amanmahajan7 as a code owner August 20, 2021 17:11
Comment thread src/HeaderCell.tsx
// handle case where the pointer `up`'d outside an iframe
// https://bugs.chromium.org/p/chromium/issues/detail?id=606896
// https://bugs.chromium.org/p/chromium/issues/detail?id=693494
onPointerUp();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
Actually the example on this page is in an iframe and it works fine, wonder what's different with the storybook.
We could remove this check 🤔

amanmahajan7
amanmahajan7 previously approved these changes Aug 20, 2021

@amanmahajan7 amanmahajan7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

😎

@nstepien
nstepien enabled auto-merge (squash) August 20, 2021 18:11
@nstepien
nstepien merged commit e622a31 into main Aug 20, 2021
@nstepien
nstepien deleted the pointer branch August 20, 2021 18:13
amanmahajan7 added a commit that referenced this pull request Nov 2, 2026
## Summary

Small accessibility fixes from an audit of the grid against Chrome's
[Modern Web
Guidance](https://developer.chrome.com/docs/modern-web-guidance)
accessibility guides. None of them change public APIs.

The group toggle changes that were in earlier commits are reverted. The
toggle will move to the group row in a separate PR.

## Changes

### Text editor (`renderTextEditor`)
- **Accessible name:** the input had none. It's now labeled with the
column's `name` when that name is a string. Columns with a React element
as their name still get no label, since there's no text to use.
- **Contrast in light mode:**

  | | Before | After | Required |
  | --- | --- | --- | --- |
  | Border | `#ccc`, 1.61:1 | `#8f8f8f`, 3.23:1 | 3:1 (WCAG 1.4.11) |
| Placeholder | `#999`, 2.85:1 | `#767676`, 4.54:1 | 4.5:1 (WCAG 1.4.3)
|

Dark mode keeps `#ccc` for the border (already 10:1) and `#999` for the
placeholder (already 5.65:1), using `light-dark()`.

### Resize handle
- **Was:** `touch-action: none` on the whole resizable header cell, so
the grid couldn't be scrolled by touch from those headers.
- **Now:** only the resize handle has it.
- **Why it was on the header:** it was added in #2595, when the handle
was a `::after` pseudo-element of the header cell. Today the handle is
its own element with its own pointer handlers.

### Reduced motion
- The sort arrow and group caret shape animations (`transition: d 0.1s`)
now run only under `@media (prefers-reduced-motion: no-preference)`.
- The frozen-column shadow's opacity fade is unchanged, since a fade
isn't the kind of motion this preference targets.

## Testing

- `vp check` and `vp run typecheck` pass.
- **New assertion:** the editor's accessible name, in
`renderTextEditor.test.tsx`.
- **Existing tests:** `TreeDataGrid`, `renderTextEditor` and `resizable`
pass.
- **Not tested automatically:** the `touch-action` move and the
reduced-motion rules, which are CSS-only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants