chore: 锚点导航标识调整为data-id (#11144)

This commit is contained in:
qkiroc 2024-11-01 18:15:27 +08:00 committed by GitHub
parent 42f2b5bdac
commit e53d6d0d0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View File

@ -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>
@ -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;

View File

@ -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"
@ -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"
@ -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"
@ -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"
@ -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"
@ -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"
@ -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"
@ -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"