Skip to content

fix(cdn-icon): fix icon update when name changes #1558

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

Merged
merged 10 commits into from
Feb 28, 2025
Merged

Conversation

spivakev
Copy link
Contributor

@spivakev spivakev commented Jan 31, 2025

Задача https://jira.moscow.alfaintra.net/browse/DS-9094

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

При изменении пропса 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: eb0530d

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 13587171395

Details

  • 30 of 39 (76.92%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 82.21%

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 13564317630: -0.02%
Covered Lines: 11266
Relevant Lines: 12500

💛 - Coveralls

@core-ds-bot
Copy link
Collaborator

core-ds-bot commented Jan 31, 2025

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

@core-ds-bot
Copy link
Collaborator

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

@core-ds-bot
Copy link
Collaborator

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

@core-ds-bot
Copy link
Collaborator

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

@spivakev spivakev requested a review from hextion February 28, 2025 09:35
@fulcanellee fulcanellee merged commit 202249e into master Feb 28, 2025
7 checks passed
@fulcanellee fulcanellee deleted the fix/DS-9094 branch February 28, 2025 12:11
fulcanellee pushed a commit that referenced this pull request Mar 4, 2025
* fix(cdn-icon): fix icon update when name changes

* refactor(cdn-icon): extract useIcon hook, add useSyncExternalStore hook

* fix(cdn-icon): add core-components-shared dependency

* chore(cdn-icon): fix quick-vans-return.md

* chore(cdn-icon): fix quick-vans-return.md

* fix: update dependencies

---------

Co-authored-by: Elena Spivak <[email protected]>
Co-authored-by: Mikhail Lukin <[email protected]>

(cherry picked from commit 202249e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants