-
Notifications
You must be signed in to change notification settings - Fork 163
[changed] Replace everything with LinkContainer #115
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
Conversation
My intent would be to release this as v0.19.0. This will allow us to close almost all the current open issues.
Very nice 👍
You've gutted it, indeed 😄
I love this. one thought. maybe we add a trigger prop that defaults to onClick? then the user can wrap stuff that triggers other events? cough menuitem
You mean for e.g. onSelect
? I looked at that a little bit but the signature doesn't quite match, since this would ignore the eventKey
.
Do you think it makes more sense to do that than to just have MenuItem
call its props.onClick
?
This looks really great! Should we consider renaming the project now that it's not specific to react-bootstrap?
That's where I started - it's a little bit specific to React-Bootstrap, though. The active
and disabled
props really match the signature of our specific components. They're somewhat generic, but not 100%.
Gotcha!
Do you think it makes more sense to do that than to just have MenuItem call its props.onClick?
I do, I was just thinking a little of both. More important to just fix the MenuItem tho. To the signature thing onSelect should provide the event first, so the preventDefault would work in that specific case. I know b/c thats what we are doing as of like 3 days ago :P
I'm a little hesitant to do that, though, because the handleClick
method from Link
specifically calls into props.onClick
, and I'd rather not copy-paste that entire method: https://github.com/rackt/react-router/blob/d88a051516d53eeb5c3fceb8f7ad0df325b3f404/modules/Link.js#L67-L68
I think I'd rather we just fix MenuItem
.
Are we okay with releasing this?
LGTM
for reference tho I meant something more like:
handleEvent(event = {}) {
var allowTransition = true
if (event.type === 'click' && isModifiedEvent(event) || !isLeftClickEvent(event))
return
if (event.defaultPrevented === true)
allowTransition = false
event.preventDefault()
if (allowTransition)
this.context.history.pushState(this.props.state, this.props.to, this.props.query)
},
render() {
var { history } = this.context
var { children, activeClassName, trigger, activeStyle, onlyActiveOnIndex, to, query, state, ...props } = this.props
;[].concat(trigger).forEach(eventName => {
props[eventName] = chain(props[eventName], this.handleEvent)
})
Makes sense - could come in handy in case those use cases come up.
[changed] Replace everything with LinkContainer
It's painful and annoying to have to make a custom
Link
component for every component we want to use.This replaces everything with a
LinkContainer
component that can wrap any React-Bootstrap component (and potentially plenty of others as well).This is also targeted against React Router v1.0.0-rc1.
As part of this, I've stripped out a number of the visual tests that were trivial/pointless (pagination and thumbnails) or wrong (the dropdown, where normal menu items ignore the injected
onClick
prop).