-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Notices: Allow link actions without requiring URLs #13009
Comments
Just realized there is a workaround for avoiding the warning if the const actions = [
{
label: 'Learn More',
url: '#',
onClick: e => {
e.preventDefault();
doSomethingWithoutRedirectToUrl();
},
},
];
<Notice status="warning" actions={ actions }>
To update, check your email and confirm your address.
</Notice> Anyway, I still think it'd great to have an |
If the action is |
I agree with you @afercia! 🙂 That's why I considered it a work-around and I still would like to see a way of defining buttons styled as links, or alternatively as primary buttons, so they can be differentiated from the notice message. |
Looking a bit better, I now understand what you meant. Sorry, I'm a bit slow 😆 So, omitting the At the very least, those buttons should be automatically styled as default buttons: Also, I understand the need to style the button as primary, when necessary. So there should be an additional prop to pass class names. From an accessibility perspective, I'm not so happy that's currently possible to pass both an An option for your use case could be passing the buttons as children: seems Gutenberg does it for the template validation notice: gutenberg/packages/editor/src/components/template-validation-notice/index.js Lines 22 to 28 in 7ea5021
but I understand that's less than ideal and this component should better handle the link / button actions. |
Is your feature request related to a problem? Please describe.
We can define an
actions
prop for theNotice
components in order to display actions related to the notice. This prop is an array of object containing 3 properties:label
,url
andonClick
.I realized that the action is only styled as a link if the
url
property is defined, but I think it should be possible to style it as a link even defining only theonClick
property.Observe how the "Learn more" action from the example below is not different from the rest of the notice message.
Describe the solution you'd like
Allow an additional property
isLink
, so the action can be styled as a link.Describe alternatives you've considered
Since the actions are styled as links if the
url
property is defined, I tried to use a hack whereurl
istrue
, so thehref
attribute of theButton
component is not set becausetrue
is not a valid value, but theisLink
prop istrue
.This works, but causes a React warning because
true
is not a valid value for thehref
attribute.The text was updated successfully, but these errors were encountered: