This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 73
Issue 280 - Refactor cell content #281
Merged
Merged
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
31aa600
bump version
7a454de
Refactor demo app
6884635
Run standalone tests for all app modes
d2f185a
Lint fix
45c7e60
Expose environment params
32e251b
Update viewport usage to virtualized + offset
ffd5d43
Lint fix
fb6068e
Apply scrolling and styling
8426c1b
Dev build
a635ac6
Add virtualization prop
4f7f989
Virtualization specific tests
6145753
Build artefacts
0e8e524
Remove duplicated tests
1fb178b
Fix regressions
2684898
Test regression
e921e61
No virtualization code if not virtualized
371fc41
Fix test regression
21a4b4a
Fix test regression
0e1fb4b
Fix styling regression
2b15526
Revert pagination_mode default change
6ecad3e
Fix visual test regression
e324db0
Virtualization review app
abc382b
Merge remote-tracking branch 'origin/master' into 3.1-issue234-virtua…
238b7b8
- refactor cellinput into cellcontent
8551e54
- add CellLabel, refactor label case
e63739a
- refactor content input and dropdown
07d4451
fix lint
80c2d3a
- fix focus regression
63efb23
- refactor dropdown as standalone component
186f284
- fix dropdown choice
57951d2
- fix navigation test regression
0f3c26b
- fix virtualization regression
886d32b
- small optimization for uiHeaders and uiCell
d51ed0c
Merge remote-tracking branch 'origin/master' into 3.1-issue234-virtua…
7a1383d
Merge remote-tracking branch 'origin/3.1-issue234-virtualization-2' i…
aac3c89
- refactor contents, clean up props and types
3c7bb28
Merge remote-tracking branch 'origin/master' into 3.1-rework-cell-con…
b6dbee2
bump version
ad5e56f
- removal conditionals of
96726d0
merge master onto 3.1-rework-cell-content
dc46220
- improve dropdown typing
891062a
- improve types
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
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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,78 @@ | ||
import React, { | ||
ChangeEvent, | ||
PureComponent | ||
} from 'react'; | ||
import Dropdown from 'react-select'; | ||
|
||
import DOM from 'core/browser/DOM'; | ||
|
||
import dropdownHelper from 'dash-table/components/dropdownHelper'; | ||
|
||
import { IDropdownOptions } from './types'; | ||
|
||
interface IProps { | ||
active: boolean; | ||
clearable?: boolean; | ||
dropdown: IDropdownOptions; | ||
onChange: (e: ChangeEvent) => void; | ||
value: any; | ||
} | ||
|
||
export default class CellDropdown extends PureComponent<IProps> { | ||
render() { | ||
const { | ||
clearable, | ||
dropdown, | ||
onChange, | ||
value | ||
} = this.props; | ||
|
||
return (<div className='dash-dropdown-cell-value-container dash-cell-value-container'> | ||
<div className='dropdown-cell-value-shadow cell-value-shadow'> | ||
{(dropdown.find(entry => entry.value === value) || { label: undefined }).label} | ||
</div> | ||
<Dropdown | ||
ref='dropdown' | ||
clearable={clearable} | ||
onChange={(newValue: any) => { | ||
onChange(newValue ? newValue.value : newValue); | ||
}} | ||
onOpen={this.handleOpenDropdown} | ||
options={dropdown} | ||
placeholder={''} | ||
value={value} | ||
/> | ||
</div>); | ||
} | ||
|
||
componentDidUpdate() { | ||
this.setFocus(); | ||
} | ||
|
||
componentDidMount() { | ||
this.setFocus(); | ||
} | ||
|
||
private setFocus() { | ||
const { active } = this.props; | ||
if (!active) { | ||
return; | ||
} | ||
|
||
const dropdown = this.refs.dropdown as any; | ||
|
||
if (dropdown && document.activeElement !== dropdown) { | ||
// Limitation. If React >= 16 --> Use React.createRef instead to pass parent ref to child | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it not be possible to pass a ref down from the parent, regardless of React >= 16? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I have in mind: ref forwarding (added in React 16.3) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah gotcha. Yeah that would be nice! |
||
const tdParent = DOM.getFirstParentOfType(dropdown.wrapper, 'td'); | ||
if (tdParent) { | ||
tdParent.focus(); | ||
} | ||
} | ||
} | ||
|
||
private handleOpenDropdown = () => { | ||
const { dropdown }: { [key: string]: any } = this.refs; | ||
|
||
dropdownHelper(dropdown.wrapper.querySelector('.Select-menu-outer')); | ||
} | ||
} |
File renamed without changes.
This file contains 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
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.
Standalone Dropdown component pulled out of pre-existing CellInput comp
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.
Nice! 👍
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.
Well it still uses react-select in the end :(