-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Adding empty class
attribute to <ul>
#9098
Comments
Thanks. This looks like a good fix, feel free (or anyone else) to submit a PR and we'll merge it Edit: PR is already there #9099 |
@slorber I think this solves the issue for the MDXUl component but will create the same problem on other custom components for ex: MDXImg. @VanTsang888 is getting an empty className instead of no property at all, and I think this is why it fails at Solution 1:I feel there should be a common function to transform className, that will handle our base condition. And then we can use the function for other components as well. function transformElement(className?: string): string | undefined {
if(className) return undefined;
return clsx(
className,
//any additional name
);
} Solution 2:We can make the change for the other custom components as well in their implementation for now, instead of creating a common function. Just to make sure we are using this behavior only when needed. @slorber Can you please suggest which approach to take here? I can create a PR after that. I am new to the community so I'm still getting used to around here. |
I have created a PR for Solution 2 #9109. Tested it my local env, will need some help writing tests for the same.
|
@thedevwonder I don't agree that this change is needed in other places, because other places usually use clsx with fixed/static classname. Those are different cases:
|
Yes, you're correct. |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
With https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/index.tsx
We have a few
<ul>
's on our website, in an MDX file, and this script seems to be adding an empty class attribute to them, which breaks our CSSul:not([class])
.Thanks to homotechsual, the fix is:
Reproducible demo
N/A
Steps to reproduce
<ul>
is now<ul class="">
.Expected behavior
The class attribute should not be added.
Actual behavior
The class attribute is added, as an empty string.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: