mantine icon indicating copy to clipboard operation
mantine copied to clipboard

className in labelProps of InputWrapper is not applied

Open Toshinaki opened this issue 2 years ago • 3 comments

What package has an issue

@mantine/core

Describe the bug

https://github.com/mantinedev/mantine/blob/master/src/mantine-core/src/components/InputWrapper/InputWrapper.tsx

    const inputLabel = createElement(
      labelElement,
      {
        ..._labelProps,
        ...labelProps,
        id: id ? `${id}-label` : undefined,
        className: classes.label,
      },
      <>
        {label}
        {required && (
          <span className={classes.required} aria-hidden>
            {' *'}
          </span>
        )}
      </>
    );

As this part of code showed, classaName provided in labelProps will be ignored.

In which browser did the problem occur

all, I think

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

No response

Possible fix

wrap the className with cx

https://github.com/mantinedev/mantine/blob/bc7e4d8cecc349821f44d4afa82e02fe646c35e9/src/mantine-core/src/components/InputWrapper/InputWrapper.tsx#L87

change this line to

cx(className, labelProps.className)

Toshinaki avatar May 05 '22 17:05 Toshinaki

You can add className to label with <InputWrapper classNames={{ label: 'my-label' }} />

rtivital avatar May 05 '22 17:05 rtivital

Yes of course. I could also add style to labelProps. But all these are but workarounds.

It would be strange not able to set className while labelProps is provided. Or is there any reason to prevent user from doing this?

Toshinaki avatar May 06 '22 01:05 Toshinaki

classNames not className

please check s

bogordesaincom avatar Jun 11 '22 18:06 bogordesaincom

Fixed in 5.0

rtivital avatar Aug 11 '22 16:08 rtivital