mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixing firing intersection on parent sections
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
0ef16fef31
commit
830eac3952
@ -38,8 +38,10 @@ export class Preferences extends React.Component {
|
||||
contentGaps={false}
|
||||
header={header}
|
||||
>
|
||||
<section id="application">
|
||||
<h1>Application</h1>
|
||||
<section id="application" title="Application">
|
||||
<section>
|
||||
<h1>Application</h1>
|
||||
</section>
|
||||
<section id="appearance">
|
||||
<h2>Appearance</h2>
|
||||
<SubTitle title="Theme"/>
|
||||
@ -87,7 +89,9 @@ export class Preferences extends React.Component {
|
||||
</section>
|
||||
|
||||
<section id="kubernetes">
|
||||
<h1>Kubernetes</h1>
|
||||
<section>
|
||||
<h1>Kubernetes</h1>
|
||||
</section>
|
||||
<section id="kubectl">
|
||||
<h2>Kubectl binary</h2>
|
||||
<KubectlBinaries preferences={preferences}/>
|
||||
@ -99,7 +103,9 @@ export class Preferences extends React.Component {
|
||||
</section>
|
||||
|
||||
<section id="extensions">
|
||||
<h1>Extensions</h1>
|
||||
<section>
|
||||
<h1>Extensions</h1>
|
||||
</section>
|
||||
{appPreferenceRegistry.getItems().map(({ title, components: { Hint, Input } }, index) => {
|
||||
return (
|
||||
<section key={index} id={title}>
|
||||
|
||||
@ -29,7 +29,7 @@ export function ScrollSpy(props: Props) {
|
||||
|
||||
sections.forEach(section => {
|
||||
const id = section.getAttribute("id");
|
||||
const name = section.querySelector(":first-child").textContent;
|
||||
const name = section.querySelector("h1, h2, h3, h4, h5, h6").textContent;
|
||||
const selected = id === activeElementId;
|
||||
|
||||
if (!name || !id) {
|
||||
@ -47,9 +47,9 @@ export function ScrollSpy(props: Props) {
|
||||
return children;
|
||||
};
|
||||
|
||||
const handleIntersect = (entries: IntersectionObserverEntry[]) => {
|
||||
if (entries[0].isIntersecting) {
|
||||
setActiveElementId(entries[0].target.id);
|
||||
const handleIntersect = ([entry]: IntersectionObserverEntry[]) => {
|
||||
if (entry.isIntersecting) {
|
||||
setActiveElementId(entry.target.closest("section[id]").id);
|
||||
}
|
||||
};
|
||||
|
||||
@ -61,8 +61,9 @@ export function ScrollSpy(props: Props) {
|
||||
|
||||
sections.current.forEach((section) => {
|
||||
const observer = new IntersectionObserver(handleIntersect, options);
|
||||
const target = section.querySelector("section") || section;
|
||||
|
||||
observer.observe(section);
|
||||
observer.observe(target);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
&.selected, &:focus {
|
||||
> .MuiTreeItem-content .MuiTreeItem-label {
|
||||
border-color: var(--blue);
|
||||
font-weight: bold;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user