Skip to content
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

fix: icon class name prefix cannot be reset back to arco #2645

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pivixl
Copy link

@Pivixl Pivixl commented Apr 21, 2024

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Documentation change
  • Coding style change
  • Component style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Typescript definition change
  • Breaking change
  • Others

Background and context

In the following scenario:

<ConfigProvider prefixCls='framework-isolation'>
  <Button />
  <IconLeft />

  <ConfigProvider prefixCls='arco'>
    <Button />
    <IconLeft />
  </ConfigProvider>

</ConfigProvider>

What to expect:

<ConfigProvider prefixCls='framework-isolation'>
  <button class="framework-isolation-button" />
  <svg class="framework-isolation-icon" />

  <ConfigProvider prefixCls='arco'>
    <button class="arco-button" />
    <svg class="arco-icon" />
  </ConfigProvider>

</ConfigProvider>

What actrually got:

<ConfigProvider prefixCls='framework-isolation'>
  <button class="framework-isolation-button" />
  <svg class="framework-isolation-icon" />

  <ConfigProvider prefixCls='arco'>
    <button class="arco-button" />
    <svg class="framework-isolation-icon" />
  </ConfigProvider>

</ConfigProvider>

The icon's class name prefix can never be set back to "arco"

Solution

How is the change tested?

Changelog

Component Changelog(CN) Changelog(EN) Related issues
fix: icon class name prefix cannot be reset back to arco

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others should be submitted to main branch)

Other information

Copy link

codesandbox bot commented Apr 21, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

Prepare preview

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

return <ConfigContext.Provider value={config}>{child}</ConfigContext.Provider>;
return (
<ConfigContext.Provider value={config}>
<IconContext.Provider value={{ prefixCls }}>{children}</IconContext.Provider>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要对 prefixCls 判空下

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是必要的吗?如果 prefixCls 没有传入或者是 undefined,它会被前面的 useMergeProps 改写回 'arco',如果它是空字符串或其他假值,整体会跟随 arco 的其他组件变成 '-icon', 'null-icon', 'NaN-icon',搭配修改 less 的 '@Prefix',这些 icon 才有样式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants