-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Button wrapped with Link from react-router does not work in Safari #850
Comments
@mariusk Could you please tell me how did you add the Link component from react-router to Button component. For example, if I do something like the following it doesn't work.
I notice that if I add |
Here's the actual code:
Without the onTouchTap handler, it works in Chrome but not in Safari. With the explicit handler (which again calls react-router's |
This might be because FlatButton generates a
One solution that I can think of is to change enhanced-button to accept an element prop that will allow users to customize the container element. So you'll be able to do:
|
You're right; button inside an a element is not valid html5. Another possible solution would be to have the button styles available for |
Actually with #846, you'll be able to do:
|
I just tested #846. It broke the styling (button text is white on white), and the link isn't active (doesn't work). Here's the actual code I tested:
|
In addition to the color issue (which was caused by my own styling), and the fact that the link still does not work, there's also a focus issue. When hovering over the embedded |
@mariusk You should be able to do this now:
|
That looks and works perfect, thanks, great work! |
When I switch to this I am getting EventEmitter memory leak warnings. I'm not sure whether it is the click handlers on |
Looks like it's now working even without |
@hai-cea nice, thx! |
containerElement is not documented :( |
I see that this setup (e.g. Any hint how to speed it up? |
@wzup just remove the |
@wzup If you write your code like this without linkButton prop, it should work. <FlatButton
containerElement={<Link to="/login" />}
/> |
@hai-cea , |
Pardon the bump but the following still generates a warning on 0.17:
Generates the following: Warning: Unknown prop |
I had the same problem, so I created a reusable component that works for me. import React from 'react';
import {Component, PropTypes} from 'react';
import FlatButton from 'material-ui/FlatButton';
export default class FlatLinkButton extends Component {
static propTypes = {
...FlatButton.propTypes,
to: PropTypes.string.isRequired,
link: PropTypes.func.isRequired,
label: PropTypes.node.isRequired,
};
render() {
const style = Object.assign({
color: 'white',
marginTop: '7px'
}, this.props.style);
const props = {
...this.props,
style,
};
delete props.to;
delete props.link;
const Link = this.props.link;
return (
<Link to={this.props.to}>
<FlatButton {...props}/>
</Link>
);
}
} Usage: import {Link} from 'react-router';
import FlatLinkButton from './FlatLinkButton';
<FlatLinkButton to="/login" link={Link} label="Login"/> |
@MatthewEdge #4670 should solve the issue |
In Material UI v1.0.0-alpha20, this does not seem to work for me: |
Hi, same problem, using v1.0.0-alpha21 for prototyping and got the message
|
@HerrVoennchen with the latest version
And then use the wrapper as the component
|
Thanks for the pointer @HiroAgustin; this seems to work in <Button
color="primary"
to={`/projects/${project.id}`}
component={props => <Link {...props}/>}
>View</Button> |
In
Any suggestions? |
@m-h-t for me it worked when I removed the curly braces:
|
@limakayo But what do you do when you would like to dynamically create the link? |
@m-h-t good question, I tested with the curly braces now and it worked, I don't know why |
anyone does know how to add a in the title of AppBar ?, I need be able to add a link on the title for 'Travel Agency'
|
we can just use like this with v1-beta
|
I think material-ui belong still old style ui frameworks , where you can't find all the button styles that you find, or simple are too much styles, if someone need customize in a low level like me , finally I'm happy with 'styled-components' no need more about css, saas,etc, just react pure components.. you lost a lot of time, days, hours, trying figure out how or where change something of if there is a bug, or wait the future release .. |
@palaniichukdmytro thanks for the solution, but it breaks the ripple styling in BottomNavigationAction |
This worked for me on a material-ui button:
|
Tried to render button with Link with the code below, but nothing's getting rendered on the view:
How else can I pass props along to the next route using material-ui? |
I have the same question - ever solve this? |
I tried this but it gives an error saying Dont use link outside a router or something.. How do I solve this now? |
React-router uses ... type components to create SPA-type navigation events. If I wrap any kind of material-ui button with Link, it works fine in Chrome, but not in Safari. In Safari, no navigation events happen. A workaround is to add an explicit
onTouchTap
handler on the button itself, but I believe this is some kind of bug.The text was updated successfully, but these errors were encountered: