alsoscotland / react-super-select

MIT License
95 stars 33 forks source link

onOpenDropdown/onCloseDropdown props #76

Closed reintroducing closed 8 years ago

reintroducing commented 8 years ago

I'm wrapping ReactSuperSelect in a custom component that handles displaying errors in the proper spot based on a prop, putting labels in correct spots, etc. I'd like to add a class to my wrapper when the dropdown is open and subsequently remove it when the dropdown is closed. I think these two props would be a welcome addition to the component.

Looking at the source it looks like this should be a pretty straightforward addition. I could even submit a PR if you'd like to add these but I'm not sure how you update all your documentation/pages that correspond.

alsoscotland commented 8 years ago

@reintroducing Just to be clear on the ask... You want a onOpenDropdown and onCloseDropdown callback prop so you can manipulate wrapping DOM if need be?

I'd be happy to accept a pull request. I can update docs accordingly. If not, I can look into this as well when on the disabled prop request

reintroducing commented 8 years ago

Yep, exactly. I see in the code that you're using the callback on setState to run a lot of methods though probably a more efficient way to do this would be in a componentDidUpdate and checking if prevState.isOpen !== this.state.isOpen and if so call the correct prop callback based on what the current state is.

I'm done for the day as its 4th of July here in the US (I assume you're in Scotland?) so we'll see who gets to this first eventually :)

EDIT: Just saw you're in Atlanta, haha.

EDIT 2: Just realized your first name is Scotland as well, face palm (no emoji for that). My apologies :)

alsoscotland commented 8 years ago

@reintroducing Hah! no worries

alsoscotland commented 8 years ago

@reintroducing added to https://github.com/alsoscotland/react-super-select/pull/79

reintroducing commented 8 years ago

Awesome, thanks!