Skip to content

Commit 9671513

Browse files
fix: Patch Jump links error (#1224)
* fix: Patch Jump links error * fix: Fix JS console error * fix: Add an auto-build fallback * fix: Add fallback properties for existing code * Update CHANGELOG-1.x.md * fix: Remove array conversion on menu_links * fix: Add backwards support for pfe-c prefixed attributes; set band height to 100% on aside when full is used * fix: Remove band package-lock * fix: Remove flex styles on band (not in a flex container) * fix: Updating demo pages to make branch testing easier * fix: Updating jump links test case to use test-fixtures and add fallback validation * fix: Update documentation * fix: Add an import in the vue test for the suite after mounted callback * fix: Simplify test page for e2e Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 53f693f commit 9671513

19 files changed

+1605
-3096
lines changed

CHANGELOG-1.x.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## 1.0.1 ( TBD )
22

3-
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Accordion assigned to content set panel was always being set to hidden
3+
- [07d1466](https://github.com/patternfly/patternfly-elements/commit/07d14667a0ed521edda8ad5d5fcc7067645c746d) fix: Accordion assigned to content set panel was always being set to hidden
4+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Jump Links fallback alias' added for old property names; additional checks on scroll
5+
46
## 1.0.0 ( 2020-12-02 )
57

68
- [e86f33e](https://github.com/patternfly/patternfly-elements/commit/e86f33e0342933f1992d52a022f9a25fd1e2fbeb) feat: Add standard attribute/property definitions

elements/pfe-band/src/pfe-band.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ $regions-grid: (
303303
}
304304

305305
.pfe-band__aside {
306-
flex-grow: 1;
307-
align-self: flex-start;
306+
height: 100%;
308307
}
309308

310309
@each $section in (header, body, footer, aside) {

elements/pfe-jump-links/README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33

44
## Usage
5-
This component is focused on reading content inside the <pfe-jump-links-panel> and updating a sidebar or horizontal nav to indicate the section of the document currently being viewed. As a developer, you have the choice of whether you bring your own markup to the nav, or have the nav build a DOM tree for you. Please note the shape of the DOM tree below. In order to support sub-section highlighting jump links must be very opinionated about the DOM tree.
5+
This component watches the content inside a `<pfe-jump-links-panel>` and updates the corresponding `<pfe-jump-links-nav>` to indicate the section of the document currently being viewed. As a developer, you have the choice of whether you bring your own markup to the navigation element or have it build for you (see `autobuild` attribute below). Please note the shape of the markup that is required. In order to support sub-section highlighting, jump links must be somewhat opinionated about the DOM tree.
66

7-
Inside of <pfe-jump-links-panel> add the class .pfe-jump-links-panel__section to tell the component to watch for when that section crosses the scroll threshold. If this section has sub-sections you add the class .has-sub-section to the section parent (i.e. section 8) and add .sub-section to the child sections (i.e. 8.1). Make sure to add an id to each section, this id should match to the href attribute of the corresponding <a> tag.
7+
Inside the `<pfe-jump-links-panel>` add the class `.pfe-jump-links-panel__section` to any elements you want the navigation to watch; when that element crosses the scroll threshold, the navigation will highlight to show it is active. If it has sub-sections, add the class `.has-sub-section` to the section parent (i.e. section 8) and add `.sub-section` to the child sections (i.e. 8.1). Make sure to add an id to each section, this id should match to the href attribute of the corresponding `<a>` tag (see below).
88

99
## Wiring up the nav
10-
The panel and nav are wired up by a scrolltarget and id. On the panel add an attribute scrolltarget="foo". This will correspond to the nav's #id. Add the corresponding id to your nav like so id="foo". The last step is to match the <a> tag's href attribute to specific sections (just like you would with same page anchor links). See below for a simple example with three sections where section two has two sub-sections:
10+
11+
The panel and nav are connected via a scrolltarget and id. On the panel, add an attribute `scrolltarget="foo"`. This will correspond to the `pfe-jump-links-nav` on the page with `id="foo"`. The last step is to match the `<a>` tag's href attribute to specific sections (just like you would with same page anchor links). See below for a simple example with three sections where section two has two sub-sections:
1112

1213
```html
1314
<pfe-jump-links-nav id="jumplinks1" default>
@@ -48,7 +49,9 @@ The panel and nav are wired up by a scrolltarget and id. On the panel add an att
4849
```
4950

5051
### Accessibility
52+
5153
The template and DOM structure of this component are as follows:
54+
5255
```html
5356
<nav>
5457
<h2 hidden>Page navigation</h2> // this is visually hidden
@@ -70,21 +73,32 @@ No extra roles or aria labels are required because we're using standard html tag
7073
## Slots
7174

7275

73-
- `pfe-jump-links-nav--heading`: The rest of the component works by creating a mirror shadowRoot based on the Light DOM markup.
76+
- `pfe-jump-links-nav--heading`: This slot is for the navigation element, `pfe-jump-links-nav` to identify the markup for the list's heading.
7477

78+
The rest of the component works by creating a mirror shadowRoot based on the Light DOM markup.
7579

76-
## Attributes
7780

81+
## Attributes
7882

7983
- `autobuild`: Flips the switch on the component to create its own markup for the navigation. You can add `pfe-jump-links-panel__section` to each section that should show in the nav. If you want to use sub-sections add `has-sub-section` to the parent section that should always show and the `sub-section` class to the children of that section. If you use this attribute, keep in mind that non-JavaScript environments (some search engines, browsers with JS disabled) will not see the proper markup.
8084

81-
- `sr-text`: This attribute is read when the component upgrades to provide the innerText of the heading. If there is no `sr-text` attribute then the component defaults to "JUMP TO SECTION". This attribute is to enable translations and internationalization.
85+
- `sr-text`: This attribute is read when the component upgrades to provide the innerText of the heading. If there is no `sr-text` attribute then the component defaults to "Jump to section". This attribute is to enable translations and internationalization.
8286

8387
- `offset`: This attribute determines the distance from the top of the browser window to trigger a switch from one link being active to the next. For instance `offset="600"` would mean that threshold flips at 600px from the top. The default is set at 200, and if you desire 200px then you can leave this attribute off. The `offset` attribute should be placed on `pfe-jump-links-panel`. There is a css solution to control the offset, however the attribute value takes precedence over css. To read more about a css solution see below.
8488

85-
- `style="--pfe-jump-links-panel--offset: {integer};"`: You can control offset in your styling layer as well. This value can be set directly on the component inside a style attribute, e.g. `style="--pfe-jump-links-panel--offset: 100;"` or using the appropriate selector in another file. Please note that adding an attribute will take precedence over a css value. At the moment only integer values passed to this key are valid. No other values are supported. This means that passing "300px", "2rem","calc(100% - 12px)" will all result in JavaScript errors. You should pass a number that correlates to pixels. To read about the `offset` attribute, see above.
89+
- `scrolltarget`: This attribute connects a `pfe-jump-links-panel` to a specific `pfe-jump-links-nav` using the ID of the navigation element. If the nav and panel are the only ones on the page, this is not necessary. If more than one of each component exists, this attribute is required.
90+
91+
## Deprecated alias attributes
92+
93+
- `pfe-c-autobuild`: Alias for autobuild.
94+
- `pfe-c-offset`: Alias for offset.
95+
- `pfe-c-scrolltarget`: Alias for scrolltarget.
96+
97+
## Custom properties
98+
99+
- `--pfe-jump-links-panel--offset: {integer}`: You can control offset in your styling layer as well. This value can be set directly on the component inside a style attribute, e.g. `style="--pfe-jump-links-panel--offset: 100;"` or using the appropriate selector in another file. Please note that adding an attribute will take precedence over a css value. At the moment only integer values passed to this key are valid. No other values are supported. This means that passing "300px", "2rem","calc(100% - 12px)" will all result in JavaScript errors. You should pass a number that correlates to pixels. To read about the `offset` attribute, see above.
86100

87-
- `style="--pfe-jump-links-panel__section--spacer: {integer}{unit};"`: pfe-jump-links are built with native behavior in terms of anchor links and scroll. That means that clicking a nav link will adjust the viewport to show the top of that section aligned with the top of the browser. This native browser is undesirable in certain cases such as working with a "sticky" navigation bar or other elements placed outside of the normal document flow. The panel components inserts a "spacer" just before each section that can be manipulated with this custom property. Specify a unit along with an integer like so: `--pfe-jump-links-panel__section--spacer: 100px;`.
101+
- `--pfe-jump-links-panel__section--spacer: {integer}{unit}`: pfe-jump-links are built with native behavior in terms of anchor links and scroll. That means that clicking a nav link will adjust the viewport to show the top of that section aligned with the top of the browser. This native browser is undesirable in certain cases such as working with a "sticky" navigation bar or other elements placed outside of the normal document flow. The panel components inserts a "spacer" just before each section that can be manipulated with this custom property. Specify a unit along with an integer like so: `--pfe-jump-links-panel__section--spacer: 100px;`.
88102

89103
## Events
90104
This component fires an event when a link is made active.

elements/pfe-jump-links/demo/demo.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ html {
33
scroll-behavior: smooth;
44
}
55

6-
:root{
6+
#nav-vars-set {
77
--pfe-navigation--Height--actual: 55px;
88
--pfe-jump-links--nav-height: 62px;
99
--pfe-jump-links-panel__section--spacer: 117px;
@@ -49,10 +49,9 @@ a.pfe-jump-links-nav__item {
4949
position: fixed;
5050
top: 0;
5151
width: 100%;
52-
overflow: hidden;
53-
background-color: #333;
5452
height: var(--pfe-navigation--Height--actual);
5553
z-index: 9;
54+
padding-top: 0;
5655
}
5756

5857
#navbar a {

0 commit comments

Comments
 (0)