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

[Table] Add column reorder handle when interaction bar enabled #1250

Merged
merged 29 commits into from
Jun 22, 2017

Conversation

cmslewis
Copy link
Contributor

@cmslewis cmslewis commented Jun 19, 2017

Fixes #1242, Fixes #1173

Checklist

  • Include tests
  • Update documentation

Changes proposed in this pull request:

Add reorder handles to column headers when useInteractionBar={true}.

  • When reorder handles are enabled, only a mousedown within the handle will trigger reordering.
  • When reorder handles are not enabled, a mousedown in the entire cell will trigger reordering, as before.
  • Clicking any reorder handle within a selection is equivalent to clicking the left-most reorder handle in the selection (the whole block moves together).
  • Clicking a reorder handle outside of the current selection will move the selection to that column on mousedown.

Also, update docs to include a new "Reorderable content" section.

Reviewers should focus on:

How does the general architecture look? Feels slightly messy, partly because I opted not to create a separate ReorderHandle component, since this logic is used in only one place (ResizeHandle, on the other hand, is used for both row and column headers.) May be passable though.

Screenshot

reorder-handle

image

/**
* Returns true if at least one item in the array satifies the predicate.
*/
export function some(a: any[] = [], predicate: (item: any) => boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-.-

// cache for easy access later in the lifecycle
const selectedInterval = isRowHeader ? selectedRegion.rows : selectedRegion.cols;
this.selectedRegionStartIndex = selectedInterval[0];
// add 1 to correct for the fencepost
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick -- can you be a little bit more descriptive here? A "because selected interval is inclusive" or "includes its endpoints" or something would be ok; just looking for a why-the-fencepost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep

@blueprint-bot
Copy link

Fix lint

Preview: documentation | table
Coverage: core | datetime

@@ -73,6 +77,7 @@ export interface IHeaderCellProps extends IProps {
export interface IInternalHeaderCellProps extends IHeaderCellProps {
/**
* Specifies if the cell is reorderable.
* @deprecated since 1.21.0; pass `isReorderable` to `ColumnHeader` or `RowHeader` instead
Copy link
Contributor Author

@cmslewis cmslewis Jun 20, 2017

Choose a reason for hiding this comment

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

@gscshoyru what do you think about this? I moved the logic for adding the TABLE_HEADER_REORDERABLE class from here into Header, so this prop serves no purpose here anymore. See: https://github.com/palantir/blueprint/pull/1250/files#diff-34e8a9161a519e81e1d774377ef4c28cR323

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine

@blueprint-bot
Copy link

Fix deprecation message

Preview: documentation | table
Coverage: core | datetime

@@ -73,6 +77,7 @@ export interface IHeaderCellProps extends IProps {
export interface IInternalHeaderCellProps extends IHeaderCellProps {
/**
* Specifies if the cell is reorderable.
* @deprecated since 1.21.0; pass `isReorderable` to `ColumnHeader` or `RowHeader` instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants