Skip to content
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

Fixed column resize on Android. #280

Merged
merged 3 commits into from Feb 7, 2018
Merged

Fixed column resize on Android. #280

merged 3 commits into from Feb 7, 2018

Conversation

davidhaimson
Copy link
Contributor

Description

  1. In FixedDataTableCell.js, fixed event handling in columnResizerComponent. The ignored events must have event.preventDefault called as well as event.stopPropagation.
  2. In vendor_upstream/dom/DOMMouseMoveTracker.js, removed handling for mouse out event.

Motivation and Context

Release 0.8.8 makes column resize work on iOS, and almost makes column resize work on Android. Our app requires that this feature work on Android.

Fixes #277

I have not modified the width of fixedDataTableCell_columnResizerKnob. Instead, I styled .public_fixedDataTableCell_columnResizerKnob in our app, increasing its width to 10px, but styling it with a linear gradient so it doesn't look twice as big.

How Has This Been Tested?

I tested this change, using our fork of fixed-data-table, in our app, on the following platforms:

  • Chrome/Android
  • Cordova/Android
  • Safari/iOS11
  • Cordova/iOS11
  • Chrome/Mac
  • Safari/Mac
  • Firefox/Mac
  • IE11/Win7
  • Edge/Win10
    Both column resize and touch scroll are configured.

npm run test: all succeed.

npm run site-dev-server: all applicable demos work as expected. There really needs to be a demo with both column resize and touch scroll configured. I'm glad to add one, but I have not done so yet.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project. (I think)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

1. In FixedDataTableCell:
- in columnResizerComponent touch handlers, also preventDefault.
- in _onColumnResizerMouseDown, also preventDefault.
1. In DOMMouseMoveTracker.js, eliminate handling the mouseout event. [The mouseout event is fired when a pointing device (usually a mouse) is moved off the element that has the listener attached or off one of its children.](https://developer.mozilla.org/en-US/docs/Web/Events/mouseout) Since the element that has the listener attached is document.body, this invariably does the wrong thing.
columnResizerComponent = (
<div
className={cx('fixedDataTableCellLayout/columnResizerContainer')}
style={columnResizerStyle}
onMouseDown={this._onColumnResizerMouseDown}
onTouchStart={this.props.touchEnabled ? this._onColumnResizerMouseDown : null}
onTouchEnd={this.props.touchEnabled ? e => e.stopPropagation() : null}
Copy link
Member

Choose a reason for hiding this comment

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

@SirGandal can you give this a quick look that it doesn't break your use case?

Copy link
Contributor

Choose a reason for hiding this comment

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

@wcjordan sorry for the late reply. That should be fine.
@davidhaimson out of curiosity, what's the reason for preventDefault in onTouchEnd and onTouchMove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First thing I tried was adding event.preventDefault() in the _onColumnResizerMouseDown method. That made a big difference on the Android devices where I was testing this. Without it, trying to resize the columns scrolled the table body left/right. I made the corresponding change here for consistency.

Because of my injury, I am working from home, and I don't have the physical devices to test on. I tried removing all the preventDefault calls, and it still works, on all the platforms, except I had to test Android and iOS in emulators. Now I don't know what to think.

I was able to test the version with all preventDefault calls in the modified demo app on a physical iPhone and Android phone, and they worked fine. My intuition is that these calls are at the very least harmless, and the one in _onColumnResizerMouseDown is necessary. But I can't prove it until I get back to work on site. Not sure when that will be - a couple of weeks, probably.

Copy link
Member

Choose a reason for hiding this comment

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

What do you want to do here? Should we wait til you're back on site and can test fully before finalizing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do that, but as I say, it'll be a couple of weeks. I already tested it fully (with the harmless, but possibly superfluous preventDefault calls). My recommendation would be to merge it in its present form. When I am back on-site, we can do a PR trimming it down to the minimum necessary.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. I'll merge and look to release over the weekend. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're a prince! Thanks.

@@ -71,11 +70,6 @@ class DOMMouseMoveTracker {
'mouseleave',
this._onMouseEnd
);
this._eventOutToken = EventListener.listen(
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for removing this rather than just fixing it?

It was added to fix #104, could you test out those cases on a few browsers? I tried in Chrome & Firefox and it seems the mouseleave event is enough for the fix to hold. @sisyphean2 do you remember why you added both mouseleave & mouseout handlers? Are there cases we should test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that because the mouseout hander was misspelled, (this.onMouseEnd instead of this._onMouseEnd) it never did anything. Fixing the spelling makes it fail miserably. No mouseout handler is needed.

@wcjordan wcjordan dismissed their stale review January 14, 2018 19:24

Not really any changes needed, just some research and see if anyone has a good memory of the related risks...

@davidhaimson
Copy link
Contributor Author

davidhaimson commented Jan 19, 2018 via email

@wcjordan
Copy link
Member

Hey David, I'm sorry to hear that, and hope you have a swift recovery. Your explanation of the changes looks good and your idea for the example as well. It may be as simple as flipping a property on.

Let's give some time for the folks I tagged to weigh in if they want. Then we can move forward w/ merging.

Get well soon & thanks!

@davidhaimson
Copy link
Contributor Author

davidhaimson commented Jan 22, 2018 via email

@@ -44,6 +44,7 @@ class ResizeExample extends React.Component {
rowsCount={dataList.getSize()}
onColumnResizeEndCallback={this._onColumnResizeEndCallback}
isColumnResizing={false}
touchScrollEnabled={true}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested the Resizable Columns demo with this change on:

  • Chrome/Android
  • Safari/iOS11
  • Chrome/Mac (both dev device mode and desktop mode)
  • Safari/Mac
  • Firefox/Mac
  • IE11/Win7
  • Edge/Win10

Works correctly everywhere except IE11/Win7, where trying to load that demo gets the error:

		SCRIPT1014: Invalid character
		File: main.js, Line: 16952, Column: 13

The character referred to is the first backquote in the following line in index.js:

      type: `webpack${type}`,

@davidhaimson
Copy link
Contributor Author

I updated the Resizable Columns demo.

columnResizerComponent = (
<div
className={cx('fixedDataTableCellLayout/columnResizerContainer')}
style={columnResizerStyle}
onMouseDown={this._onColumnResizerMouseDown}
onTouchStart={this.props.touchEnabled ? this._onColumnResizerMouseDown : null}
onTouchEnd={this.props.touchEnabled ? e => e.stopPropagation() : null}
Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. I'll merge and look to release over the weekend. Thanks

@wcjordan wcjordan merged commit 839dc0f into schrodinger:master Feb 7, 2018
@wcjordan
Copy link
Member

wcjordan commented Feb 7, 2018

Merged and released w/ 0.8.10

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.

Column resize doesn't work on Android
3 participants