我尝试使用Multiple Select。但我有所不同,是当选择了很多项目时,它们没有被查看,我无法将高度更改为足以显示所选项目。请帮忙。
我确定它是height
属性,因为我使用chrome控制台添加了height:auto
,因此可以在控制台查看所选选项并解决问题。您可以指导我正确添加高度功能。可以在样式中将height
添加到chips
样式。
顺便说一下,问题没出现在我今天在其上测试的create-react-app的新副本上,但是我面临这个问题的项目是基于一个很长时间生成的create-project-app以前,我认为更新或创建反应应用程序版本会有所不同。
材料用户界面版本:v1.0.0-beta.33
的package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": {
"auth/google": {
"target": "https://server243.azurewebsites.net"
},
"/api/*": {
"target": "https://server243.azurewebsites.net"
},
"/apis/*": {
"target": "https://server243.azurewebsites.net"
}
},
"dependencies": {
"autoprefixer": "7.1.6",
"aws-amplify": "^0.2.0",
"aws-amplify-react-native": "^0.2.2",
"axios": "^0.17.1",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.1.0",
"babel-runtime": "6.26.0",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"css-loader": "0.28.7",
"dotenv": "4.0.0",
"eslint": "4.10.0",
"eslint-config-react-app": "^2.0.1",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"fs-extra": "3.0.1",
"html-webpack-plugin": "2.29.0",
"jest": "20.0.4",
"jquery": "^3.2.1",
"material-ui": "^1.0.0-beta.24",
"material-ui-icons": "^1.0.0-beta.17",
"materialize-css": "^0.100.2",
"moment": "^2.20.1",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.8",
"promise": "8.0.1",
"prop-types": "^15.6.0",
"raf": "3.4.0",
"react": "^16.0.0",
"react-bootstrap": "^0.31.5",
"react-dev-utils": "^4.2.1",
"react-dom": "^16.0.0",
"react-hot-loader": "^3.1.3",
"react-loader": "^2.4.2",
"react-loading-skeleton": "^0.3.1",
"react-moment": "^0.6.8",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-select": "^1.0.0-rc.10",
"react-select-me": "^0.9.0",
"react-virtualized-select": "^3.1.0",
"redux": "^3.7.2",
"redux-auth": "0.0.5-beta5",
"redux-auth-wrapper": "^2.0.2",
"redux-thunk": "^2.2.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
"universal-cookie": "^2.1.2",
"url-loader": "0.6.2",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.3",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom",
"cypress:open": "cypress open"
},
"devDependencies": {
"cypress": "^1.4.1"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,mjs}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"mjs",
"js",
"json",
"web.jsx",
"jsx",
"node"
]
},
"babel": {
"presets": [
"react-app"
]
},
"eslintConfig": {
"extends": "react-app"
}
}
临时解决方案:我更新了node_modules \ material-ui \ Select \ Select.js中的height
和padding
,但我希望我能以正确的方式解决它。
selectMenu: {
width: 'auto', // Fix Safari textOverflow
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
lineHeight: 'calc(1em + ' + (theme.spacing.unit * 2 - 2) + 'px)',
// I, abdulrhman, added the following:
height:'auto',
paddingTop: 20,
},
答案 0 :(得分:1)
我相信SelectField
将在较新版本的测试版中具有预期的行为。您应该尝试在撰写本文时更新到最新版本(material-ui^1.0.0-beta.33
)。
您可以使用npm
命令更新到此版本:
npm install --save material-ui@1.0.0-beta.33