-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: forward and back buttons for organize column search #1620
Merged
ethanalvizo
merged 15 commits into
deephaven:main
from
ethanalvizo:1529-organize-col-search-button
Nov 14, 2023
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
49565fd
wip
ethanalvizo 996ec93
update icon
ethanalvizo 39eef3e
initial draft
ethanalvizo 9506c57
style fixes
ethanalvizo 89b60ff
feat: forward and back buttons to organize column search
ethanalvizo 64da0ff
Merge branch 'main' into 1529-organize-col-search-button
ethanalvizo 24eb74b
update snapshots
ethanalvizo 7d828eb
scroll item into view
ethanalvizo edc7d23
update button component used
ethanalvizo af2ca84
UX improvement
ethanalvizo 6e7569d
Merge branch 'main' into 1529-organize-col-search-button
ethanalvizo 1c2d5bd
add unit test
ethanalvizo 000288c
fix scroll into behaviour
ethanalvizo 4712199
style changes
ethanalvizo 1d43453
refactor search input
ethanalvizo 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
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 |
---|---|---|
|
@@ -67,6 +67,8 @@ interface VisibilityOrderingBuilderProps { | |
|
||
interface VisibilityOrderingBuilderState { | ||
selectedColumns: Set<string>; | ||
queriedColumnIndex: number | undefined; | ||
prevQueriedColumns: string[] | undefined; | ||
lastSelectedColumn: string; | ||
searchFilter: string; | ||
} | ||
|
@@ -100,6 +102,8 @@ class VisibilityOrderingBuilder extends Component< | |
|
||
this.state = { | ||
selectedColumns: new Set(), | ||
queriedColumnIndex: undefined, | ||
prevQueriedColumns: undefined, | ||
lastSelectedColumn: '', | ||
searchFilter: '', | ||
}; | ||
|
@@ -125,6 +129,8 @@ class VisibilityOrderingBuilder extends Component< | |
|
||
this.setState({ | ||
selectedColumns: new Set(), | ||
queriedColumnIndex: undefined, | ||
prevQueriedColumns: undefined, | ||
lastSelectedColumn: '', | ||
searchFilter: '', | ||
}); | ||
|
@@ -135,7 +141,12 @@ class VisibilityOrderingBuilder extends Component< | |
} | ||
|
||
resetSelection(): void { | ||
this.setState({ selectedColumns: new Set(), lastSelectedColumn: '' }); | ||
this.setState({ | ||
selectedColumns: new Set(), | ||
queriedColumnIndex: undefined, | ||
prevQueriedColumns: undefined, | ||
lastSelectedColumn: '', | ||
}); | ||
} | ||
|
||
handleSearchInputChange(event: ChangeEvent<HTMLInputElement>): void { | ||
|
@@ -168,6 +179,58 @@ class VisibilityOrderingBuilder extends Component< | |
this.list?.querySelectorAll('.item-wrapper')[visibleIndexToFocus]; | ||
columnItemToFocus?.scrollIntoView({ block: 'center' }); | ||
} | ||
|
||
this.setState({ | ||
prevQueriedColumns: columnsMatch, | ||
queriedColumnIndex: undefined, | ||
}); | ||
} | ||
|
||
/** | ||
* Change the selected column to either the next or previous column | ||
* | ||
* @param direction The direction to move the selection | ||
*/ | ||
|
||
changeSelectedColumn(direction: 'forward' | 'back'): void { | ||
const { queriedColumnIndex, prevQueriedColumns } = this.state; | ||
let newQueriedColumnIndex = queriedColumnIndex; | ||
|
||
if (prevQueriedColumns === undefined) return; | ||
|
||
if (direction === 'forward') { | ||
if ( | ||
newQueriedColumnIndex === undefined || | ||
newQueriedColumnIndex >= prevQueriedColumns.length - 1 | ||
) { | ||
newQueriedColumnIndex = 0; | ||
} else { | ||
newQueriedColumnIndex += 1; | ||
} | ||
} else if (direction === 'back') { | ||
if (newQueriedColumnIndex === undefined || newQueriedColumnIndex <= 0) { | ||
newQueriedColumnIndex = prevQueriedColumns.length - 1; | ||
} else { | ||
newQueriedColumnIndex -= 1; | ||
} | ||
} | ||
|
||
this.addColumnToSelected( | ||
[prevQueriedColumns[newQueriedColumnIndex as number]], | ||
false | ||
); | ||
|
||
const flattenedItems = flattenTree(this.getTreeItems()); | ||
const actualColumnIndex = flattenedItems.findIndex( | ||
item => item.id === prevQueriedColumns[newQueriedColumnIndex as number] | ||
); | ||
const columnItemToFocus = | ||
this.list?.querySelectorAll('.item-wrapper')[actualColumnIndex]; | ||
columnItemToFocus?.scrollIntoView({ block: 'center' }); | ||
|
||
this.setState({ | ||
queriedColumnIndex: newQueriedColumnIndex, | ||
}); | ||
} | ||
|
||
/** | ||
|
@@ -1015,7 +1078,12 @@ class VisibilityOrderingBuilder extends Component< | |
|
||
render(): ReactElement { | ||
const { model, hiddenColumns, onColumnVisibilityChanged } = this.props; | ||
const { selectedColumns, searchFilter } = this.state; | ||
const { | ||
selectedColumns, | ||
searchFilter, | ||
prevQueriedColumns, | ||
queriedColumnIndex, | ||
} = this.state; | ||
const hasSelection = selectedColumns.size > 0; | ||
const treeItems = this.getTreeItems(); | ||
const nameToIndexes = new Map( | ||
|
@@ -1049,6 +1117,14 @@ class VisibilityOrderingBuilder extends Component< | |
treeItems | ||
); | ||
|
||
const queryParams = { | ||
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. i thought this would be nicer to pass in to SearchInput rather than creating two new optional props that would only be used by VisibilityOrderingBuilder. Could revert to that if preferred though |
||
queriedColumnIndex, | ||
changeQueriedColumnIndex: (direction: 'forward' | 'back') => | ||
this.changeSelectedColumn(direction), | ||
}; | ||
|
||
const matchCount = prevQueriedColumns?.length; | ||
|
||
return ( | ||
<div role="menu" className="visibility-ordering-builder" tabIndex={0}> | ||
<div className="top-menu"> | ||
|
@@ -1067,8 +1143,9 @@ class VisibilityOrderingBuilder extends Component< | |
<SearchInput | ||
className="visibility-search" | ||
value={searchFilter} | ||
matchCount={searchFilter ? selectedColumns.size : undefined} | ||
matchCount={searchFilter ? matchCount : undefined} | ||
onChange={this.handleSearchInputChange} | ||
queryParams={queryParams} | ||
/> | ||
</div> | ||
<div className="top-menu"> | ||
|
Binary file modified
BIN
+624 Bytes
(100%)
tests/table-operations.spec.ts-snapshots/organize-columns-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-303 Bytes
(98%)
tests/table-operations.spec.ts-snapshots/organize-columns-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-356 Bytes
(98%)
tests/table-operations.spec.ts-snapshots/organize-columns-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
i feel this could use a better name but not too sure what. This does change the selected column as the name implies but only from the previously queried list