-
Notifications
You must be signed in to change notification settings - Fork 2.9k
DetailsList: headers now resize again. #4325
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
20bfbe6
Fixing a bug introduced by the DetailsHaeder.
dzearing 8b17444
Fix for detailsheader resizing.
dzearing bfab5d1
Adding change files.
dzearing 328ccf1
Fixing build error.
dzearing bdb218c
Removing unnecessary null.
dzearing 7d4dd72
Fixing import?
dzearing d7244ea
Merge branch 'master' into detailsheader-fix
dzearing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@uifabric/utilities/detailsheader-fix_2018-03-21-00-31.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@uifabric/utilities", | ||
| "comment": "EventGroup.raise: event args are now correctly mixed into the event object.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@uifabric/utilities", | ||
| "email": "dzearing@microsoft.com" | ||
| } |
11 changes: 11 additions & 0 deletions
11
common/changes/office-ui-fabric-react/detailsheader-fix_2018-03-21-00-31.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "DetailsList: headers now resize correctly and respect maxWidth.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "dzearing@microsoft.com" | ||
| } |
83 changes: 83 additions & 0 deletions
83
packages/office-ui-fabric-react/src/components/DetailsList/DetailsHeader.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import * as React from 'react'; | ||
| import { DetailsHeader } from './DetailsHeader'; | ||
| import { DetailsListLayoutMode } from './DetailsList.types'; | ||
| import { Selection, SelectionMode } from '../../utilities/selection/index'; | ||
| import { EventGroup } from '../../Utilities'; | ||
| import { mount } from 'enzyme'; | ||
| import * as renderer from 'react-test-renderer'; | ||
|
|
||
| const _items: {}[] = []; | ||
| const _selection = new Selection(); | ||
|
|
||
| _selection.setItems(_items); | ||
|
|
||
| describe('DetailsHeader', () => { | ||
|
|
||
| it('can render', () => { | ||
| const component = renderer.create( | ||
| <DetailsHeader | ||
| selection={ _selection } | ||
| selectionMode={ SelectionMode.multiple } | ||
| layoutMode={ DetailsListLayoutMode.fixedColumns } | ||
| columns={ [ | ||
| { key: 'a', name: 'a', fieldName: 'a', minWidth: 200, maxWidth: 400, calculatedWidth: 200, isResizable: true }, | ||
| { key: 'b', name: 'b', fieldName: 'a', minWidth: 200, maxWidth: 400, calculatedWidth: 200, isResizable: true } | ||
| ] } | ||
| /> | ||
| ); | ||
| expect(component.toJSON()).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('can resize columns', () => { | ||
| let header: any; | ||
| let lastResize = { size: -1, index: -1 }; | ||
|
|
||
| const wrapper = mount( | ||
| <DetailsHeader | ||
| componentRef={ h => header = h } | ||
| selection={ _selection } | ||
| selectionMode={ SelectionMode.multiple } | ||
| layoutMode={ DetailsListLayoutMode.fixedColumns } | ||
| columns={ [ | ||
| { key: 'a', name: 'a', fieldName: 'a', minWidth: 200, maxWidth: 400, calculatedWidth: 200, isResizable: true }, | ||
| { key: 'b', name: 'b', fieldName: 'a', minWidth: 200, maxWidth: 400, calculatedWidth: 200, isResizable: true } | ||
| ] } | ||
| onColumnResized={ (column, size, index) => lastResize = { size, index } } | ||
| /> | ||
| ); | ||
|
|
||
| const rootElement = wrapper.getDOMNode(); | ||
| const sizerElement = wrapper.find('[data-sizer-index=0]').getDOMNode(); | ||
|
|
||
| // Trigger a mousedown, which validates that the ref to focuszone is hooking up events. | ||
| EventGroup.raise( | ||
| sizerElement, | ||
| 'mousedown', | ||
| { | ||
| clientX: 0, | ||
| button: 0 | ||
| }, | ||
| true | ||
| ); | ||
|
|
||
| // Validate we go into resize mode. | ||
| expect(sizerElement.classList.contains('is-resizing')).toBe(true); | ||
| expect(!!wrapper.state().isSizing).toBe(false); | ||
|
|
||
| // Mouse move 1 pixel to the right to get into sizing mode. | ||
| wrapper.simulate('mousemove', { clientX: 1 }); | ||
| expect(!!wrapper.state().isSizing).toBe(true); | ||
|
|
||
| // The header is 200; move mouse 100 to the right, the header should be 300. | ||
| header._onSizerMouseMove({ clientX: 100 }); | ||
| expect(lastResize).toEqual({ index: 0, size: 300 }); | ||
|
|
||
| // Mouse move 300 pixels to the right (should be capped at 400px width | ||
| header._onSizerMouseMove({ clientX: 300 }); | ||
| expect(lastResize).toEqual({ index: 0, size: 400 }); | ||
|
|
||
| // Complete sizing. | ||
| header._onSizerMouseUp(); | ||
| expect(!!wrapper.state().isSizing).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
217 changes: 217 additions & 0 deletions
217
...fice-ui-fabric-react/src/components/DetailsList/__snapshots__/DetailsHeader.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,217 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`DetailsHeader can render 1`] = ` | ||
| <div | ||
| aria-describedby={undefined} | ||
| aria-label={undefined} | ||
| aria-labelledby={undefined} | ||
| className="ms-FocusZone ms-DetailsHeader" | ||
| data-automationid="DetailsHeader" | ||
| data-focuszone-id="FocusZone1" | ||
| onFocus={[Function]} | ||
| onKeyDown={[Function]} | ||
| onMouseDownCapture={[Function]} | ||
| onMouseMove={[Function]} | ||
| role="row" | ||
| > | ||
| <div | ||
| aria-colindex={0} | ||
| aria-labelledby="header0-check" | ||
| className="ms-DetailsHeader-cell ms-DetailsHeader-cellIsCheck" | ||
| onClick={[Function]} | ||
| role="columnheader" | ||
| > | ||
| <span | ||
| className="" | ||
| > | ||
| <div | ||
| aria-checked={undefined} | ||
| aria-describedby="header0-checkTooltip" | ||
| aria-label={undefined} | ||
| className="ms-DetailsRow-check ms-DetailsRow-check--isHeader undefined" | ||
| data-automationid="DetailsRowCheck" | ||
| data-is-focusable={true} | ||
| data-selection-toggle={true} | ||
| id="header0-check" | ||
| role="checkbox" | ||
| > | ||
| <div | ||
| className= | ||
| ms-Check | ||
| { | ||
| height: 18px; | ||
| line-height: 1; | ||
| position: relative; | ||
| user-select: none; | ||
| vertical-align: top; | ||
| width: 18px; | ||
| } | ||
| &:before { | ||
| background: #ffffff; | ||
| border-radius: 50%; | ||
| bottom: 1px; | ||
| content: ""; | ||
| left: 1px; | ||
| opacity: 1; | ||
| position: absolute; | ||
| right: 1px; | ||
| top: 1px; | ||
| } | ||
| .checkHost:hover &, .checkHost:focus &, &:hover, &:focus { | ||
| opacity: 1; | ||
| } | ||
| > | ||
| <i | ||
| aria-hidden={true} | ||
| className= | ||
| ms-Check-circle | ||
| { | ||
| display: inline-block; | ||
| } | ||
| { | ||
| color: #c8c8c8; | ||
| font-size: 18px; | ||
| height: 18px; | ||
| left: 0px; | ||
| position: absolute; | ||
| text-align: center; | ||
| top: 0px; | ||
| vertical-align: middle; | ||
| width: 18px; | ||
| } | ||
| @media screen and (-ms-high-contrast: active){& { | ||
| color: WindowText; | ||
| } | ||
| data-icon-name="CircleRing" | ||
| role="presentation" | ||
| /> | ||
| <i | ||
| aria-hidden={true} | ||
| className= | ||
| ms-Check-check | ||
| { | ||
| display: inline-block; | ||
| } | ||
| { | ||
| color: #c8c8c8; | ||
| font-size: 16px; | ||
| height: 18px; | ||
| left: .5px; | ||
| opacity: 0; | ||
| position: absolute; | ||
| text-align: center; | ||
| top: 0px; | ||
| vertical-align: middle; | ||
| width: 18px; | ||
| } | ||
| &:hover { | ||
| opacity: 1; | ||
| } | ||
| @media screen and (-ms-high-contrast: active){& { | ||
| -ms-high-contrast-adjust: none; | ||
| } | ||
| data-icon-name="StatusCircleCheckmark" | ||
| role="presentation" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </span> | ||
| </div> | ||
| <div | ||
| aria-colindex={1} | ||
| aria-disabled={false} | ||
| aria-sort="none" | ||
| className="ms-DetailsHeader-cell is-actionable undefined" | ||
| data-automationid="ColumnsHeaderColumn" | ||
| data-item-key="a" | ||
| role="columnheader" | ||
| style={ | ||
| Object { | ||
| "width": 216, | ||
| } | ||
| } | ||
| > | ||
| <span | ||
| className="" | ||
| > | ||
| <span | ||
| aria-describedby="header0-a-tooltip" | ||
| aria-haspopup={false} | ||
| aria-label={undefined} | ||
| aria-labelledby="header0-a-name " | ||
| className="ms-DetailsHeader-cellTitle" | ||
| data-is-focusable={true} | ||
| id="header0-a" | ||
| onClick={[Function]} | ||
| onContextMenu={[Function]} | ||
| role="button" | ||
| > | ||
| <span | ||
| className="ms-DetailsHeader-cellName" | ||
| id="header0-a-name" | ||
| > | ||
| a | ||
| </span> | ||
| </span> | ||
| </span> | ||
| </div> | ||
| <div | ||
| aria-hidden={true} | ||
| className="ms-DetailsHeader-cellSizer" | ||
| data-is-focusable={false} | ||
| data-sizer-index={0} | ||
| onBlur={[Function]} | ||
| onClick={[Function]} | ||
| onDoubleClick={[Function]} | ||
| role="button" | ||
| /> | ||
| <div | ||
| aria-colindex={2} | ||
| aria-disabled={false} | ||
| aria-sort="none" | ||
| className="ms-DetailsHeader-cell is-actionable undefined" | ||
| data-automationid="ColumnsHeaderColumn" | ||
| data-item-key="b" | ||
| role="columnheader" | ||
| style={ | ||
| Object { | ||
| "width": 216, | ||
| } | ||
| } | ||
| > | ||
| <span | ||
| className="" | ||
| > | ||
| <span | ||
| aria-describedby="header0-b-tooltip" | ||
| aria-haspopup={false} | ||
| aria-label={undefined} | ||
| aria-labelledby="header0-b-name " | ||
| className="ms-DetailsHeader-cellTitle" | ||
| data-is-focusable={true} | ||
| id="header0-b" | ||
| onClick={[Function]} | ||
| onContextMenu={[Function]} | ||
| role="button" | ||
| > | ||
| <span | ||
| className="ms-DetailsHeader-cellName" | ||
| id="header0-b-name" | ||
| > | ||
| b | ||
| </span> | ||
| </span> | ||
| </span> | ||
| </div> | ||
| <div | ||
| aria-hidden={true} | ||
| className="ms-DetailsHeader-cellSizer" | ||
| data-is-focusable={false} | ||
| data-sizer-index={1} | ||
| onBlur={[Function]} | ||
| onClick={[Function]} | ||
| onDoubleClick={[Function]} | ||
| role="button" | ||
| /> | ||
| </div> | ||
| `; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Did you find a way to remove the any?