Skip to content

Commit

Permalink
chore: 锚点导航标识调整为data-id (#11144)
Browse files Browse the repository at this point in the history
  • Loading branch information
qkiroc authored Nov 1, 2024
1 parent 42f2b5b commit e53d6d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/amis-ui/src/components/AnchorNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AnchorNavSectionComponent extends React.PureComponent<AnchorNavSectionProp
<div
ref={this.contentRef}
className={cx('AnchorNav-section', className)}
id={name + ''}
data-id={name + ''}
>
{children}
</div>
Expand Down Expand Up @@ -98,7 +98,7 @@ export class AnchorNav extends React.Component<AnchorNavProps> {
@autobind
scrollToNav(entries: IntersectionObserverEntry[]) {
entries.forEach(entry => {
const key = entry.target.id;
const key = entry.target.getAttribute('data-id');
const currentSection = this.sections.find(item => item.key === key);
if (currentSection) {
currentSection.isIntersecting = entry.isIntersecting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports[`Renderer:anchorNav 1`] = `
>
<div
class="cxd-AnchorNav-section"
id="0"
data-id="0"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -180,7 +180,7 @@ exports[`Renderer:anchorNav 1`] = `
</div>
<div
class="cxd-AnchorNav-section"
id="1"
data-id="1"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -305,7 +305,7 @@ exports[`Renderer:anchorNav 1`] = `
</div>
<div
class="cxd-AnchorNav-section"
id="2"
data-id="2"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -645,7 +645,7 @@ exports[`Renderer:anchorNav with children 1`] = `
>
<div
class="cxd-AnchorNav-section"
id="0"
data-id="0"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -770,7 +770,7 @@ exports[`Renderer:anchorNav with children 1`] = `
</div>
<div
class="cxd-AnchorNav-section"
id="0-0"
data-id="0-0"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -895,7 +895,7 @@ exports[`Renderer:anchorNav with children 1`] = `
</div>
<div
class="cxd-AnchorNav-section"
id="0-1"
data-id="0-1"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -1020,7 +1020,7 @@ exports[`Renderer:anchorNav with children 1`] = `
</div>
<div
class="cxd-AnchorNav-section"
id="1"
data-id="1"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down Expand Up @@ -1189,7 +1189,7 @@ exports[`Renderer:anchorNav with horizontal 1`] = `
>
<div
class="cxd-AnchorNav-section"
id="0"
data-id="0"
>
<div
class="cxd-Panel cxd-Panel--default cxd-Panel--form"
Expand Down

0 comments on commit e53d6d0

Please sign in to comment.