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

feat(space): add current key for Item #1395

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

Conversation

VladislavNsk
Copy link
Contributor

@VladislavNsk VladislavNsk commented Sep 25, 2024

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

При использовании компонента Space, если удалить дочерний элемент, то все остальные элементы размонитруются и смонтируются заново, при условии что key никак не меняется при этом

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

Добавить в Space несколько элементов и после удалить первый

<Space>
  {rows.map(({text, id}) => (
      <Component key={id}>
        {text}
      </Component>        
  ))}
</Space>
<button>
 Удалить первую строку
</button>

Пример можно посмотреть тут
https://codesandbox.io/s/infallible-water-27jjg5?file=/src/index.js

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

Удалится первый элемент, остальные никак не среагируют на это

Чек лист

  • Тесты
  • Документация

Copy link

changeset-bot bot commented Sep 25, 2024

🦋 Changeset detected

Latest commit: f58c8dd

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

This PR includes changesets to release 13 packages
Name Type
@alfalab/core-components-checkbox Patch
@alfalab/core-components-custom-picker-button Patch
@alfalab/core-components-gallery Patch
@alfalab/core-components-icon-view Patch
@alfalab/core-components-input-autocomplete Patch
@alfalab/core-components-international-phone-input Patch
@alfalab/core-components-intl-phone-input Patch
@alfalab/core-components-picker-button Patch
@alfalab/core-components-select Patch
@alfalab/core-components-select-with-tags Patch
@alfalab/core-components-space Patch
@alfalab/core-components-table Patch
@alfalab/core-components-tabs 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 Sep 25, 2024

Pull Request Test Coverage Report for Build 11323854846

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 25 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-0.03%) to 82.601%

Files with Coverage Reduction New Missed Lines %
packages/date-time-input/src/utils/format.ts 1 92.86%
packages/pure-cell/src/components/amount/component.tsx 1 82.86%
packages/pure-cell/src/components/amount-title/component.tsx 1 86.11%
packages/phone-input/src/Component.tsx 3 90.32%
packages/select/src/presets/useSelectWithApply/options-list-with-apply/header/Component.tsx 6 45.45%
packages/select/src/presets/useSelectWithApply/hook.tsx 13 70.18%
Totals Coverage Status
Change from base Build 11013175941: -0.03%
Covered Lines: 10342
Relevant Lines: 11450

💛 - Coveralls

@@ -121,7 +121,7 @@ export const Space = forwardRef<HTMLDivElement, SpaceProps>((props, ref) => {
<Item
className={itemClassName}
dividerClassName={styles.divider}
key={`${itemClassName}-${i}`}
key={(child as ReactElement).key}
Copy link
Collaborator

Choose a reason for hiding this comment

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

import {isValidElement} from 'react';

key={isValidElement(child) ? child.key : `${itemClassName}-${i}`}

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.

4 participants