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(cdn-icon): fix icon update when name changes #1558

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

spivakev
Copy link

@spivakev spivakev commented Jan 31, 2025

Опишите проблему

При изменении пропса name CDNIсon не перерисовывает иконку

Шаги для воспроизведения

  1. Перейти в песочницу https://core-ds.github.io/core-components/master/?path=/docs/sandbox--docs
  2. Вставить следующий пример:
function Example() {
    const [name, setName] = React.useState('glyph_airplane_m');
    return (
        <div>
            <CDNIcon name={name}/>
            <Gap size={16}/>
            <Button onClick={() => setName('glyph_diamonds_m')}>
                diamond icon
            </Button>
            <Gap size={16}/>
            <Button onClick={() => setName('glyph_apelsin_m_color')}>
                orange icon
            </Button>
        </div>
    );
}
render(
    <Example />
)
  1. Нажатием кнопок попробовать сменить иконку

Ожидаемое поведение

  1. По клику на кнопку иконка меняется на соответствующую
  2. При повторном клике в дальнейшем на эту же кнопку, запрос не вызывается, но иконка меняется (работает кеширование)

Copy link

changeset-bot bot commented Jan 31, 2025

🦋 Changeset detected

Latest commit: 3c7696b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@alfalab/core-components-cdn-icon Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link

coveralls commented Jan 31, 2025

Pull Request Test Coverage Report for Build 13333281601

Details

  • 30 of 39 (76.92%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.0%) to 83.507%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/cdn-icon/src/hooks/use-icon.tsx 26 35 74.29%
Totals Coverage Status
Change from base Build 13330488117: 1.0%
Covered Lines: 7668
Relevant Lines: 8447

💛 - Coveralls

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

@core-ds-bot
Copy link
Collaborator

Собрана новая демка.

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.

6 participants