mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Ensure all AutoComplete popover are visible on screen (even if on the bottom of the window)
This commit is contained in:
@@ -10,6 +10,7 @@ import { Line } from '../../UI/Grid';
|
|||||||
import mapValues from 'lodash/mapValues';
|
import mapValues from 'lodash/mapValues';
|
||||||
import AutoComplete from 'material-ui/AutoComplete';
|
import AutoComplete from 'material-ui/AutoComplete';
|
||||||
import RaisedButton from 'material-ui/RaisedButton';
|
import RaisedButton from 'material-ui/RaisedButton';
|
||||||
|
import { defaultAutocompleteProps } from '../../UI/AutocompleteProps';
|
||||||
|
|
||||||
type Props = {|
|
type Props = {|
|
||||||
runtimeScene: GameData,
|
runtimeScene: GameData,
|
||||||
@@ -127,11 +128,8 @@ export default class RuntimeSceneInspector extends React.Component<
|
|||||||
runtimeScene._objects.items && (
|
runtimeScene._objects.items && (
|
||||||
<Line noMargin alignItems="baseline">
|
<Line noMargin alignItems="baseline">
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
hintText="Enter the name of the object"
|
hintText="Enter the name of the object"
|
||||||
fullWidth
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
searchText={this.state.newObjectName}
|
searchText={this.state.newObjectName}
|
||||||
onUpdateInput={value => {
|
onUpdateInput={value => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@@ -1,13 +1,8 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import AutoComplete from 'material-ui/AutoComplete';
|
import AutoComplete from 'material-ui/AutoComplete';
|
||||||
|
import { defaultAutocompleteProps } from '../../../UI/AutocompleteProps';
|
||||||
const gd = global.gd;
|
const gd = global.gd;
|
||||||
|
|
||||||
const styles = {
|
|
||||||
autoCompleteTextField: {
|
|
||||||
minWidth: 300,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const fuzzyFilterOrEmpty = (searchText, key) => {
|
const fuzzyFilterOrEmpty = (searchText, key) => {
|
||||||
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
||||||
};
|
};
|
||||||
@@ -104,12 +99,8 @@ export default class BehaviorField extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
floatingLabelText={this._description}
|
floatingLabelText={this._description}
|
||||||
fullWidth
|
|
||||||
textFieldStyle={styles.autoCompleteTextField}
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
errorText={
|
errorText={
|
||||||
!this._behaviorNames.length
|
!this._behaviorNames.length
|
||||||
? noBehaviorErrorText
|
? noBehaviorErrorText
|
||||||
|
@@ -7,12 +7,7 @@ import {
|
|||||||
enumerateExternalEvents,
|
enumerateExternalEvents,
|
||||||
} from '../../../ProjectManager/EnumerateProjectItems';
|
} from '../../../ProjectManager/EnumerateProjectItems';
|
||||||
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
||||||
|
import { defaultAutocompleteProps } from '../../../UI/AutocompleteProps';
|
||||||
const styles = {
|
|
||||||
autoCompleteTextField: {
|
|
||||||
minWidth: 300,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const fuzzyFilterOrEmpty = (searchText, key) => {
|
const fuzzyFilterOrEmpty = (searchText, key) => {
|
||||||
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
||||||
@@ -79,13 +74,9 @@ export default class ExternalEventsField extends Component<
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
floatingLabelText={this._description}
|
floatingLabelText={this._description}
|
||||||
fullWidth
|
|
||||||
id="external-events-field"
|
id="external-events-field"
|
||||||
textFieldStyle={styles.autoCompleteTextField}
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
searchText={this.state.focused ? this.state.text : this.props.value}
|
searchText={this.state.focused ? this.state.text : this.props.value}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@@ -2,12 +2,7 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import AutoComplete from 'material-ui/AutoComplete';
|
import AutoComplete from 'material-ui/AutoComplete';
|
||||||
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
||||||
|
import { defaultAutocompleteProps } from '../../../UI/AutocompleteProps';
|
||||||
const styles = {
|
|
||||||
autoCompleteTextField: {
|
|
||||||
minWidth: 300,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const fuzzyFilterOrEmpty = (searchText, key) => {
|
const fuzzyFilterOrEmpty = (searchText, key) => {
|
||||||
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
||||||
@@ -131,12 +126,8 @@ export default class KeyField extends Component<ParameterFieldProps, State> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
floatingLabelText={this._description}
|
floatingLabelText={this._description}
|
||||||
fullWidth
|
|
||||||
textFieldStyle={styles.autoCompleteTextField}
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
searchText={this.state.focused ? this.state.text : this.props.value}
|
searchText={this.state.focused ? this.state.text : this.props.value}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@@ -3,12 +3,7 @@ import React, { Component } from 'react';
|
|||||||
import AutoComplete from 'material-ui/AutoComplete';
|
import AutoComplete from 'material-ui/AutoComplete';
|
||||||
import { mapFor } from '../../../Utils/MapFor';
|
import { mapFor } from '../../../Utils/MapFor';
|
||||||
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
||||||
|
import { defaultAutocompleteProps } from '../../../UI/AutocompleteProps';
|
||||||
const styles = {
|
|
||||||
autoCompleteTextField: {
|
|
||||||
minWidth: 300,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const fuzzyFilterOrEmpty = (searchText, key) => {
|
const fuzzyFilterOrEmpty = (searchText, key) => {
|
||||||
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
return !key || AutoComplete.fuzzyFilter(searchText, key);
|
||||||
@@ -63,12 +58,8 @@ export default class LayerField extends Component<ParameterFieldProps, State> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
floatingLabelText={this._description}
|
floatingLabelText={this._description}
|
||||||
fullWidth
|
|
||||||
textFieldStyle={styles.autoCompleteTextField}
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
searchText={this.state.focused ? this.state.text : this.props.value}
|
searchText={this.state.focused ? this.state.text : this.props.value}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@@ -4,6 +4,7 @@ import AutoComplete from 'material-ui/AutoComplete';
|
|||||||
import RaisedButton from 'material-ui/RaisedButton';
|
import RaisedButton from 'material-ui/RaisedButton';
|
||||||
import { enumerateVariables } from './EnumerateVariables';
|
import { enumerateVariables } from './EnumerateVariables';
|
||||||
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
|
||||||
|
import { defaultAutocompleteProps } from '../../../UI/AutocompleteProps';
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
container: {
|
container: {
|
||||||
@@ -13,9 +14,6 @@ const styles = {
|
|||||||
moreButton: {
|
moreButton: {
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
},
|
},
|
||||||
autoCompleteTextField: {
|
|
||||||
minWidth: 300,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fuzzyFilterOrEmpty = (searchText, key) => {
|
const fuzzyFilterOrEmpty = (searchText, key) => {
|
||||||
@@ -72,12 +70,8 @@ export default class VariableField extends Component<Props, State> {
|
|||||||
return (
|
return (
|
||||||
<div style={styles.container}>
|
<div style={styles.container}>
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
floatingLabelText={this._description}
|
floatingLabelText={this._description}
|
||||||
fullWidth
|
|
||||||
textFieldStyle={styles.autoCompleteTextField}
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
searchText={this.state.focused ? this.state.text : this.props.value}
|
searchText={this.state.focused ? this.state.text : this.props.value}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@@ -3,16 +3,7 @@ import AutoComplete from 'material-ui/AutoComplete';
|
|||||||
import Divider from 'material-ui/Divider';
|
import Divider from 'material-ui/Divider';
|
||||||
import { enumerateObjectsAndGroups } from './EnumerateObjects';
|
import { enumerateObjectsAndGroups } from './EnumerateObjects';
|
||||||
import { fuzzyOrEmptyFilter } from '../Utils/FuzzyOrEmptyFilter';
|
import { fuzzyOrEmptyFilter } from '../Utils/FuzzyOrEmptyFilter';
|
||||||
|
import { defaultAutocompleteProps } from '../UI/AutocompleteProps';
|
||||||
const styles = {
|
|
||||||
autoCompleteTextField: {
|
|
||||||
minWidth: 300,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const popoverProps = {
|
|
||||||
canAutoPosition: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class ObjectSelector extends Component {
|
export default class ObjectSelector extends Component {
|
||||||
state = {
|
state = {
|
||||||
@@ -79,11 +70,7 @@ export default class ObjectSelector extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
fullWidth
|
{...defaultAutocompleteProps}
|
||||||
textFieldStyle={styles.autoCompleteTextField}
|
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
searchText={this.state.focused ? this.state.text : value}
|
searchText={this.state.focused ? this.state.text : value}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -116,7 +103,6 @@ export default class ObjectSelector extends Component {
|
|||||||
dataSource={this.fullList}
|
dataSource={this.fullList}
|
||||||
filter={fuzzyOrEmptyFilter}
|
filter={fuzzyOrEmptyFilter}
|
||||||
ref={field => (this._field = field)}
|
ref={field => (this._field = field)}
|
||||||
popoverProps={popoverProps}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@@ -10,6 +10,7 @@ import {
|
|||||||
type ChooseResourceFunction,
|
type ChooseResourceFunction,
|
||||||
type ResourceKind,
|
type ResourceKind,
|
||||||
} from '../ResourcesList/ResourceSource.flow';
|
} from '../ResourcesList/ResourceSource.flow';
|
||||||
|
import { defaultAutocompleteProps } from '../UI/AutocompleteProps';
|
||||||
|
|
||||||
type Props = {|
|
type Props = {|
|
||||||
project: gdProject,
|
project: gdProject,
|
||||||
@@ -152,6 +153,7 @@ export default class ResourceSelector extends React.Component<Props, State> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
{...defaultAutocompleteProps}
|
||||||
floatingLabelText={this.props.floatingLabelText || 'Select an image'}
|
floatingLabelText={this.props.floatingLabelText || 'Select an image'}
|
||||||
filter={fuzzyOrEmptyFilter}
|
filter={fuzzyOrEmptyFilter}
|
||||||
openOnFocus
|
openOnFocus
|
||||||
@@ -162,9 +164,6 @@ export default class ResourceSelector extends React.Component<Props, State> {
|
|||||||
searchText={this.state.resourceName}
|
searchText={this.state.resourceName}
|
||||||
fullWidth={this.props.fullWidth}
|
fullWidth={this.props.fullWidth}
|
||||||
style={styles.autoComplete}
|
style={styles.autoComplete}
|
||||||
menuProps={{
|
|
||||||
maxHeight: 250,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
19
newIDE/app/src/UI/AutocompleteProps.js
Normal file
19
newIDE/app/src/UI/AutocompleteProps.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides props for material-ui AutoComplete components that specify
|
||||||
|
* sensible defaults for size and popover size/positioning.
|
||||||
|
*/
|
||||||
|
export const defaultAutocompleteProps = {
|
||||||
|
fullWidth: true,
|
||||||
|
textFieldStyle: {
|
||||||
|
minWidth: 300,
|
||||||
|
},
|
||||||
|
menuProps: {
|
||||||
|
maxHeight: 250, //TODO: try put it in PopoverProps
|
||||||
|
},
|
||||||
|
popoverProps: {
|
||||||
|
// Ensure that the Popover menu is always visible on screen
|
||||||
|
canAutoPosition: true,
|
||||||
|
},
|
||||||
|
};
|
Reference in New Issue
Block a user