Skip to content
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

SelectField/DropDownMenu not working #1011

Closed
solchea opened this issue Jul 1, 2015 · 46 comments
Closed

SelectField/DropDownMenu not working #1011

solchea opened this issue Jul 1, 2015 · 46 comments
Labels
bug 🐛 Something doesn't work external dependency Blocked by external dependency, we can’t do anything about it

Comments

@solchea
Copy link

solchea commented Jul 1, 2015

Having an odd problem where the SelectField isn't working - it renders, but isn't clickable. Other form fields work just fine. No events for the DropDownMenu seem to be firing. Anyone else have this problem or know what could be causing this? I've run the examples and they work fine locally, so the only difference I know of is my build process but I can't imagine that would be causing this problem. And here's the code I'm using:

<SelectField floatingLabelText="Your Department" menuItems={departments} />
<DropDownMenu menuItems={departments} />
@tylermichael
Copy link
Contributor

Try putting this in your build:

var injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();

Make sure that function is ran before you render anything to page.

@solchea
Copy link
Author

solchea commented Jul 2, 2015

Thanks for the suggestion, I had the injectTapEventPlugin() firing on page load and just checked and it's definitely firing before I try to render the components, but it's still not working. This is how it's rendering, not sure if it helps diagnose what's going on.

screen shot 2015-07-01 at 5 42 03 pm

@tylermichael
Copy link
Contributor

Are these drop downs coming up when you click them?
screenshot 2015-07-01 21 37 41

For the SelectField, do you have a value prop and an onChange handler?
See here for an example: https://github.com/callemall/material-ui/blob/master/docs/src/app/components/pages/components/text-fields.jsx#L332-L337

@solchea
Copy link
Author

solchea commented Jul 2, 2015

Nope, drop-downs do not show up on click. I've tried attaching an onClick handler on the component itself and it still doesn't work. If I wrap the component with a div and put an onClick on the div, the event triggers just fine. And yes, I do have a value prop and onChange handler and it still isn't working.

@hai-cea
Copy link
Member

hai-cea commented Jul 13, 2015

@solchea Are you getting any errors in the console?

@zachguo
Copy link
Contributor

zachguo commented Jul 24, 2015

I can confirm, dropdown is showing up for me but floatingLabelText is jammed with input like @solchea's picture above. hintText also has no effect.

@zachguo
Copy link
Contributor

zachguo commented Jul 24, 2015

I fix my problem by passing a value={undefined} to SelectField.
edit:
But after I select an option, contents become jammed again when not focused.
edit:
Everything works fine if value is assigned an integer value.

@williamakehurst
Copy link

I'm having the same problem in my project with both SelectFields and DropDownMenu. They render, and on render flash the option values, then the are not selectable at all. @solchea Did you find a solution?

@bdefore
Copy link

bdefore commented Sep 11, 2015

Same here. Clicking doesn't open the dropdown.

@simtechmedia
Copy link

Also not working for me when compiled into my project

@levbrie
Copy link

levbrie commented Sep 18, 2015

importing injectTapEventPlugin worked for me:

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

but I have to say, the amount of setup required in order to do anything of use with material-ui is pretty burdensome. Things that are required in order for a component to work should come with that component automatically. material-ui requires some pretty elaborate rituals, especially if you're using es6 syntax.

@bdefore
Copy link

bdefore commented Sep 18, 2015

forgot to follow up but just the requiring of injecttapevent worked for me
too at least enough to get the drop down opening. but the lack of
consistence with other components led me back to using text field for what
we needed. curious to see what the rewrite of drop down does.

On Friday, September 18, 2015, Lev Brie notifications@github.com wrote:

importing injectTapEventPlugin worked for me:

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

but I have to say, the amount of setup required in order to do anything of
use with material-ui is pretty burdensome. Things that are required in
order for a component to work should come with that component
automatically. material-ui requires some pretty elaborate rituals,
especially if you're using es6 syntax.


Reply to this email directly or view it on GitHub
#1011 (comment)
.

@MikeB2012
Copy link

This worked: var injectTapEventPlugin = require('react-tap-event-plugin'); injectTapEventPlugin();
The challenge then became that the first item in the selection list was rendered over the 'hint' text. My solution was to just have a blank item at the top of drop down items ie.[ {payload:'', text ''}, ...]

@bendiy
Copy link

bendiy commented Nov 18, 2015

Related:
#1427
#1195
#2183

@bendiy
Copy link

bendiy commented Nov 18, 2015

I'm having this same problem after upgrading to 0.13.3 from 0.13.0 on a DatePicker. If I have a floatingLabelText set for the DatePicker, the date picker dialog window will not pup up unless I click outside of the label text value. Clicking directly on the floatingLabelText does not bring up the date picker dialog. Clicking to the right of it or below it does bring up the date modal.

@dangerismycat
Copy link

I'm having this problem as well, with both floating text (large, gray, overlapping) and being unclickable. injectTapEventPlugin helps, but doesn't fully solve: on initial render, the floating text problem remains. But the SelectField is clickable, and upon selecting an option, the floating text renders correctly. (If you click but don't select an option, the render remains incorrect.)

@alitaheri alitaheri added bug 🐛 Something doesn't work external dependency Blocked by external dependency, we can’t do anything about it labels Dec 8, 2015
@MarkLeMerise
Copy link

I still cannot get a <SelectField> or <DropdownField> to display on click, and have pretty much exhausted every solution in this thread:

  1. injectTapEventPlugin() as high up in my script as possible, before rendering (@tylermichael)
  2. Wrapping the component with <div onClick={}> (@solchea)
  3. Setting value to undefined (@zachguo)
  4. Adding an "empty" option (@MikeB2012)

For sanity, when setting the openImmediately to true, I saw the dropdown with the options populated, so I know the data structure is being read correctly, but I couldn't select any of the options.

For reference, I tried this with react@0.14.3 and material-ui@0.13.4, and a few other combinations with earlier React versions down to 0.14.0, as well as material-ui@0.14.0-rc1 (tested on Chrome Canary, vanilla Chrome, and Firefox). Still looking for the winning combination 😕

@alitaheri
Copy link
Member

@MarkLeMerise Can you try with the latest master branch? SelectField and DropDownMenu now use Popover. maybe that fixes it?

@gravitypersists
Copy link

I'm seeing this with React 14 as well. Specifically, the label text is coming down over the option text.
bug
0.14.0-rc2

@bdefore
Copy link

bdefore commented Dec 22, 2015

@gravitypersists are you setting value, per the idea of being a controlled component?

@gravitypersists
Copy link

Ah. I hadn't gotten to that part yet, I just assumed it was broken. I would still consider this an issue, though, as all other controlled components work fine without the value set.

I also needed to prepend a blank menuItem to avoid overlap on first render.

Finally, I don't understand why the docs don't include the two most important pieces of information: the format the component expect menuItems in and the format of the value. http://www.material-ui.com/#/components/select-fields

Is this by, somewhat flawed, design? Or is it just missing? I don't mind submitting a PR clearing it up, it just seems too obvious to go missing in documentation...

@bendiy
Copy link

bendiy commented Dec 22, 2015

Same issue here:
#1427 (comment)

@oliviertassinari
Copy link
Member

@gravitypersists The docs was missing a lot of information... This should be fixed with #2565.

@scarletsky
Copy link
Contributor

be03f314-16c9-450e-9dfd-e75df69eb8f7

@oliviertassinari After upgrading to 0.14.0, I get lots of error when using SelectField. I think the deprecated information should be a warning, not an error.

@alitaheri
Copy link
Member

@scarletsky It IS a warning, only in form of an error to contain the stack trace. it won't halt execution. it's just red.

@scarletsky
Copy link
Contributor

@alitaheri Oh, I see... What I want is to follow the warning, use composability instead of menuItems. But I've check the docs, I can not get any useful info to migrate, because the SelectField section still use menuItems...

@alitaheri
Copy link
Member

@scarletsky Yes SelectField is still old. I'm working on it to migrate. the 0.14.1 will be brand new 😁
For now just follow the docs on DropDownMenu it's the exact same usage. compose them like that. sorry for the inconvenience, I'm working on it ^_^

@scarletsky
Copy link
Contributor

@alitaheri OK, thanks for the information. Hoping 0.14.1 release ! 😃

@maxkrieger
Copy link

👍 making value an int works

@Eyesonly88
Copy link

For people that use redux-devtools + hot reloading, I had to injectTapEventPlugin() everytime the app is rendered (when the store state changes) otherwise it won't work after the initial load. Thought I'd add it here in case other people hit this problem.

@oliviertassinari
Copy link
Member

@Eyesonly88 That's not convenient. Can we do something about it?

@Eyesonly88
Copy link

@oliviertassinari I'm not quite sure as I don't know why injectTapEventPlugin is needed in the first place. My app is relatively small so I'm not seeing any performance hit from doing this workaround but it is definitely not ideal.

@alendit
Copy link

alendit commented Jan 11, 2016

For what it's worth: there is a bug in react-tap-event-plugin which prevents tap events from working when a parent element stops event propagation on bubbling. See zilverline/react-tap-event-plugin#54 for more precise description and a working example.

Since material-ui only listens on touchTap , many element stop working when onTapEvent isn't fired.

@jbq
Copy link

jbq commented Jan 26, 2016

I'm affected by this bug and spent several hours trying to figure out what was going wrong. May I suggest to issue a warning in the console when a dependency such as the tap event plugin is not met?

@oliviertassinari
Copy link
Member

spent several hours trying to figure out what was going wrong

You can't imagine how many hours were spent on this bug :/. That's a very good idea. I'm gonna try. I'm tired of the noise it's adding to our issue reporting tool.

@austinmao
Copy link

+1 I am seeing this issue. In rare instances, the SelectField dropdown works when I refresh. I am not sure why. I have also tried these:

  1. injectTapEventPlugin() as high up in my script as possible, before rendering (@tylermichael)
  2. Setting value to undefined (@zachguo)
  3. Adding an "empty" option (@MikeB2012)

@dczii
Copy link

dczii commented Feb 23, 2016

I got the same issue as @austinmao any solutions?

@dczii
Copy link

dczii commented Feb 23, 2016

solved this by adding these codes before any imports. I suggest put it in the 1st line of app.js

const injectTouchTapEvent = require('react-tap-event-plugin');
injectTouchTapEvent();

@oliviertassinari
Copy link
Member

I think that we can close this issue now.

@mbrookes
Copy link
Member

Agree.

@JuoCode
Copy link

JuoCode commented Apr 22, 2016

@alitaheri Use the latest 0.15.0-beta.2 still not work :(

@coocssweb
Copy link

coocssweb commented Apr 28, 2016

@mbrookes this issue still existence at the version 0.14.4 . I still cannot get a to display on click。
no getting any errors in the console!how can i fix it?

Edit

I fixed it , by :
npm install react-tap-event-plugin^0.2.0

and add

var injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();

in my components。

thank you。.....

@mobimation
Copy link

I assume the injectTapEventPlugin() call is a bug workaround ?

@frankdavidcorona
Copy link

Work for me using react-tap-event-plugin

@lojones
Copy link

lojones commented Aug 31, 2017

same issue for me and this workaround

var injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();

worked for me, but can someone explain why this works?

@negarineh
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work external dependency Blocked by external dependency, we can’t do anything about it
Projects
None yet
Development

No branches or pull requests