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: added ref support to Sider component #29169

Merged
merged 2 commits into from
Feb 2, 2021
Merged

feat: added ref support to Sider component #29169

merged 2 commits into from
Feb 2, 2021

Conversation

qramilq
Copy link
Contributor

@qramilq qramilq commented Feb 1, 2021

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

The problem was that the component did not support ref prop. The solution allows to work with DOM-node (<aside/> tag)

📝 Changelog

Language Changelog
🇺🇸 English added ref support to Layout.Sider component
🇨🇳 Chinese 向Layout.Sider組件添加了ref支持

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Feb 1, 2021

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 1, 2021

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.

Latest deployment of this branch, based on commit 1289660:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Feb 1, 2021

Codecov Report

Merging #29169 (1289660) into feature (40663fb) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           feature    #29169   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          393       393           
  Lines         7496      7497    +1     
  Branches      2154      2154           
=========================================
+ Hits          7496      7497    +1     
Impacted Files Coverage Δ
components/layout/Sider.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40663fb...1289660. Read the comment docs.

@afc163
Copy link
Member

afc163 commented Feb 2, 2021

Could you add test case?

@qramilq
Copy link
Contributor Author

qramilq commented Feb 2, 2021

Could you add test case?

@afc163 yes, where can I see example of needed test (maybe in other component)?

@afc163
Copy link
Member

afc163 commented Feb 2, 2021

it('should get input element from ref', () => {
const ref = React.createRef();
const onSelect = jest.fn();
const wrapper = mount(<Input.Password onSelect={onSelect} ref={ref} />);
expect(ref.current.input instanceof HTMLInputElement).toBe(true);
wrapper.find('input').simulate('select');
expect(onSelect).toHaveBeenCalled();
});

Comment on lines 298 to 299
wrapper.find('aside').simulate('select');
expect(onSelect).toHaveBeenCalled();
Copy link
Member

Choose a reason for hiding this comment

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

onSelect is unneccessary.

@afc163 afc163 merged commit 9f0e5e5 into ant-design:feature Feb 2, 2021
@qramilq qramilq deleted the feature-sider-ref branch February 2, 2021 12:51
qramilq added a commit to qramilq/ant-design that referenced this pull request Feb 5, 2021
* feat: added ref support to Sider component

* test: updated Layout tests (check for ref)

Co-authored-by: Аюпов Рамиль Ильдарович <RAyupov@stream.ru>
mumiao pushed a commit to mumiao/ant-design that referenced this pull request Feb 20, 2021
* feat: added ref support to Sider component

* test: updated Layout tests (check for ref)

Co-authored-by: Аюпов Рамиль Ильдарович <RAyupov@stream.ru>
@zombieJ zombieJ mentioned this pull request Feb 28, 2021
15 tasks
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.

3 participants