Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
3be357b2
Commit
3be357b2
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Improve performance of table column dragging
parent
8c767e9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/visualizations/components/TableInteractive.jsx
+23
-27
23 additions, 27 deletions
...c/metabase/visualizations/components/TableInteractive.jsx
with
23 additions
and
27 deletions
frontend/src/metabase/visualizations/components/TableInteractive.jsx
+
23
−
27
View file @
3be357b2
...
...
@@ -28,6 +28,8 @@ const HEADER_HEIGHT = 36;
const
ROW_HEIGHT
=
30
;
const
MIN_COLUMN_WIDTH
=
ROW_HEIGHT
;
const
RESIZE_HANDLE_WIDTH
=
5
;
// if header is dragged fewer than than this number of pixels we consider it a click instead of a drag
const
HEADER_DRAG_THRESHOLD
=
5
;
// HACK: used to get react-draggable to reset after a drag
let
DRAG_COUNTER
=
0
;
...
...
@@ -269,13 +271,20 @@ export default class TableInteractive extends Component {
});
}
visualizationIsClickable
(
clicked
)
{
const
{
onVisualizationClick
,
visualizationIsClickable
}
=
this
.
props
;
const
{
dragColIndex
}
=
this
.
state
;
return
(
// don't bother calling if we're dragging
dragColIndex
==
null
&&
onVisualizationClick
&&
visualizationIsClickable
&&
visualizationIsClickable
(
clicked
)
);
}
cellRenderer
=
({
key
,
style
,
rowIndex
,
columnIndex
}:
CellRendererProps
)
=>
{
const
{
data
,
isPivoted
,
onVisualizationClick
,
visualizationIsClickable
,
}
=
this
.
props
;
const
{
data
,
isPivoted
,
onVisualizationClick
}
=
this
.
props
;
const
{
rows
,
cols
}
=
data
;
const
column
=
cols
[
columnIndex
];
...
...
@@ -288,8 +297,7 @@ export default class TableInteractive extends Component {
columnIndex
,
isPivoted
,
);
const
isClickable
=
onVisualizationClick
&&
visualizationIsClickable
(
clicked
);
const
isClickable
=
this
.
visualizationIsClickable
(
clicked
);
return
(
<
div
...
...
@@ -389,12 +397,7 @@ export default class TableInteractive extends Component {
}
tableHeaderRenderer
=
({
key
,
style
,
columnIndex
}:
CellRendererProps
)
=>
{
const
{
sort
,
isPivoted
,
onVisualizationClick
,
visualizationIsClickable
,
}
=
this
.
props
;
const
{
sort
,
isPivoted
,
onVisualizationClick
}
=
this
.
props
;
// $FlowFixMe: not sure why flow has a problem with this
const
{
cols
}
=
this
.
props
.
data
;
const
column
=
cols
[
columnIndex
];
...
...
@@ -415,9 +418,7 @@ export default class TableInteractive extends Component {
}
const
isDragging
=
this
.
state
.
dragColIndex
===
columnIndex
;
const
isClickable
=
onVisualizationClick
&&
visualizationIsClickable
(
clicked
);
const
isClickable
=
this
.
visualizationIsClickable
(
clicked
);
const
isSortable
=
isClickable
&&
column
.
source
;
const
isRightAligned
=
isColumnRightAligned
(
column
);
...
...
@@ -456,7 +457,10 @@ export default class TableInteractive extends Component {
dragColIndex
!==
dragColNewIndex
)
{
this
.
onColumnReorder
(
dragColIndex
,
dragColNewIndex
);
}
else
if
(
Math
.
abs
(
d
.
x
)
+
Math
.
abs
(
d
.
y
)
<
5
)
{
}
else
if
(
isClickable
&&
Math
.
abs
(
d
.
x
)
+
Math
.
abs
(
d
.
y
)
<
HEADER_DRAG_THRESHOLD
)
{
// in setTimeout since headers will be rerendered due to DRAG_COUNTER changing
setTimeout
(()
=>
{
onVisualizationClick
({
...
...
@@ -578,15 +582,7 @@ export default class TableInteractive extends Component {
return
(
<
ScrollSync
>
{
({
clientHeight
,
clientWidth
,
onScroll
,
scrollHeight
,
scrollLeft
,
scrollTop
,
scrollWidth
,
})
=>
(
{
({
onScroll
,
scrollLeft
,
scrollTop
})
=>
(
<
div
className
=
{
cx
(
className
,
"
TableInteractive relative
"
,
{
"
TableInteractive--pivot
"
:
this
.
props
.
isPivoted
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment