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(Anchor): allow replacing in anchor #43006

Merged

Conversation

ds1371dani
Copy link
Contributor

@ds1371dani ds1371dani commented Jun 14, 2023

[中文版模板 / Chinese template]

🤔 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
  • Workflow
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

The Anchor component should allow user to replace each item's href in browser history, because there are situations where we need a back button to take user to previous page, but currently when user clicks the back button he's sent back to the previous selected item in Anchor.

📝 Changelog

Language Changelog
🇺🇸 English 🆕 Anchor Add replace prop
🇨🇳 Chinese 🆕 为 Anchor 添加 replace 属性

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • 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

🚀 Summary

🤖 Generated by Copilot at 343684e

Added a new replace feature to the Anchor and AnchorLink components to allow users to choose the history mode for the anchor navigation. Updated the documentation and demo code in both English and Chinese languages to reflect the new feature. Reordered some imports to follow the code style guidelines.

🔍 Walkthrough

🤖 Generated by Copilot at 343684e

  • Add replace prop to Anchor and AnchorLink components to control history behavior (link, link, link, link, link, link)
  • Modify handleClick function in AnchorLink component to use window.location.replace method if replace is true (link)
  • Create replace.md and replace.tsx files to provide documentation and code example for the new feature (link, link)
  • Update index.en-US.md and index.zh-CN.md files to include the new feature in the Examples, Anchor Props and AnchorItem sections (link, link, link, link, link, link)
  • Reorder imports in Anchor.tsx and AnchorLink.tsx files to follow code style guidelines (link, link)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 14, 2023

@kiner-tang kiner-tang changed the title Feat/allow replacing in anchor feat(Anchor): allow replacing in anchor Jun 14, 2023
Copy link
Member

@kiner-tang kiner-tang left a comment

Choose a reason for hiding this comment

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

Can you provide a test case to test it?

components/anchor/index.en-US.md Outdated Show resolved Hide resolved
components/anchor/index.en-US.md Outdated Show resolved Hide resolved
components/anchor/index.zh-CN.md Outdated Show resolved Hide resolved
components/anchor/index.zh-CN.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 14, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (5d62e63) 100.00% compared to head (de50b84) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##           feature    #43006   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          649       650    +1     
  Lines        10936     10956   +20     
  Branches      2965      2971    +6     
=========================================
+ Hits         10936     10956   +20     
Impacted Files Coverage Δ
components/anchor/Anchor.tsx 100.00% <100.00%> (ø)
components/anchor/AnchorLink.tsx 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

ds1371dani and others added 6 commits June 14, 2023 10:12
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
@kiner-tang
Copy link
Member

The coverage is down, need fix it.

@ds1371dani
Copy link
Contributor Author

The coverage is down, need fix it.

It's because of the default href value in AnchorLink component. href prop is required, is it okay to remove the default value?

components/anchor/demo/replace.md Outdated Show resolved Hide resolved
components/anchor/demo/replace.md Outdated Show resolved Hide resolved
ds1371dani and others added 2 commits June 18, 2023 12:31
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
Co-authored-by: kiner-tang(文辉) <1127031143@qq.com>
@kiner-tang kiner-tang merged commit 4af6a52 into ant-design:feature Jun 18, 2023
51 checks passed
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