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
0354580c
Commit
0354580c
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Add inheritWidth prop to ItemSelect, default true
parent
565082db
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/containers/ItemSelect.jsx
+24
-1
24 additions, 1 deletion
frontend/src/metabase/containers/ItemSelect.jsx
with
24 additions
and
1 deletion
frontend/src/metabase/containers/ItemSelect.jsx
+
24
−
1
View file @
0354580c
import
React
from
"
react
"
;
import
ReactDOM
from
"
react-dom
"
;
import
PropTypes
from
"
prop-types
"
;
import
PopoverWithTrigger
from
"
metabase/components/PopoverWithTrigger
"
;
import
SelectButton
from
"
metabase/components/SelectButton
"
;
const
MIN_POPOVER_WIDTH
=
300
;
export
default
(
PickerComponent
,
NameComponent
,
type
)
=>
class
ItemSelect
extends
React
.
Component
{
state
=
{
width
:
null
,
};
static
propTypes
=
{
// collection ID, null (for root collection), or undefined
value
:
PropTypes
.
number
,
...
...
@@ -13,12 +20,23 @@ export default (PickerComponent, NameComponent, type) =>
field
:
PropTypes
.
object
.
isRequired
,
// optional collectionId to filter out so you can't move a collection into itself
collectionId
:
PropTypes
.
number
,
// make the popover content inherit the select widget's width
inheritWidth
:
PropTypes
.
bool
,
};
static
defaultProps
=
{
placeholder
:
`Select a
${
type
}
`
,
inheritWidth
:
true
,
};
componentDidUpdate
()
{
// save the width so we can make the poopver content match
const
width
=
ReactDOM
.
findDOMNode
(
this
).
clientWidth
;
if
(
this
.
state
.
width
!==
width
)
{
this
.
setState
({
width
});
}
}
render
()
{
const
{
value
,
...
...
@@ -26,6 +44,7 @@ export default (PickerComponent, NameComponent, type) =>
className
,
style
,
placeholder
,
inheritWidth
,
...
props
}
=
this
.
props
;
return
(
...
...
@@ -45,7 +64,11 @@ export default (PickerComponent, NameComponent, type) =>
{
({
onClose
})
=>
(
<
PickerComponent
{
...
props
}
style
=
{
{
minWidth
:
300
}
}
style
=
{
inheritWidth
?
{
width
:
this
.
state
.
width
}
:
{
minWidth
:
MIN_POPOVER_WIDTH
}
}
className
=
"p2 overflow-auto"
value
=
{
value
}
onChange
=
{
itemId
=>
{
...
...
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