Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
layout_paragraphs
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
layout_paragraphs
Commits
7867d10e
Commit
7867d10e
authored
4 weeks ago
by
Justin Toupin
Browse files
Options
Downloads
Patches
Plain Diff
Correctly manage visibility of UI elements
parent
8ed4f1b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#430167
failed
4 weeks ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/builder.js
+17
-9
17 additions, 9 deletions
js/builder.js
with
17 additions
and
9 deletions
js/builder.js
+
17
−
9
View file @
7867d10e
...
@@ -59,6 +59,19 @@
...
@@ -59,6 +59,19 @@
});
});
}
}
/**
* Sets the visibility of UI elements based on the data-active attribute.
*/
function
setUiElementVisibility
()
{
selectAll
(
'
.js-lpb-component .js-lpb-ui
'
).
forEach
((
element
)
=>
{
if
(
element
.
closest
(
'
.js-lpb-component
'
)?.
getAttribute
(
'
data-active
'
))
{
element
.
classList
.
remove
(
'
visually-hidden
'
);
}
else
{
element
.
classList
.
add
(
'
visually-hidden
'
);
}
});
}
/**
/**
* Removes focus data attributes from all components.
* Removes focus data attributes from all components.
*/
*/
...
@@ -72,9 +85,7 @@
...
@@ -72,9 +85,7 @@
selectAll
(
'
.is-navigating
'
).
forEach
((
element
)
=>
selectAll
(
'
.is-navigating
'
).
forEach
((
element
)
=>
element
.
classList
.
remove
(
'
is-navigating
'
),
element
.
classList
.
remove
(
'
is-navigating
'
),
);
);
selectAll
(
'
.js-lpb-ui:not(.visually-hidden)
'
).
forEach
((
element
)
=>
setUiElementVisibility
();
element
.
classList
.
add
(
'
visually-hidden
'
),
);
}
}
/**
/**
...
@@ -87,9 +98,7 @@
...
@@ -87,9 +98,7 @@
// Add the data-active attribute to the element.
// Add the data-active attribute to the element.
element
.
setAttribute
(
'
data-active
'
,
'
true
'
);
element
.
setAttribute
(
'
data-active
'
,
'
true
'
);
element
.
setAttribute
(
'
data-active-within
'
,
'
true
'
);
element
.
setAttribute
(
'
data-active-within
'
,
'
true
'
);
selectAll
(
'
.js-lpb-ui
'
,
element
)
setUiElementVisibility
();
.
filter
((
uiElement
)
=>
uiElement
.
closest
(
'
.js-lpb-component
'
)
===
element
)
.
forEach
((
uiElement
)
=>
uiElement
.
classList
.
remove
(
'
visually-hidden
'
));
// Add the data-active-within attribute to all parent elements.
// Add the data-active-within attribute to all parent elements.
let
parent
=
element
.
parentNode
.
closest
(
'
.js-lpb-component
'
);
let
parent
=
element
.
parentNode
.
closest
(
'
.js-lpb-component
'
);
while
(
parent
)
{
while
(
parent
)
{
...
@@ -160,10 +169,9 @@
...
@@ -160,10 +169,9 @@
const
containerUiElements
=
uiElements
[
id
]
||
[];
const
containerUiElements
=
uiElements
[
id
]
||
[];
Object
.
values
(
containerUiElements
).
forEach
((
uiElement
)
=>
{
Object
.
values
(
containerUiElements
).
forEach
((
uiElement
)
=>
{
const
{
element
,
method
}
=
uiElement
;
const
{
element
,
method
}
=
uiElement
;
$container
[
method
](
$container
[
method
](
$
(
element
).
addClass
(
'
js-lpb-ui
'
));
$
(
element
).
addClass
(
'
js-lpb-ui
'
).
addClass
(
'
visually-hidden
'
),
);
});
});
setUiElementVisibility
();
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment