Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue #6109 - aria-current has incorrect value "true" #6118

Merged
merged 2 commits into from
May 8, 2018

Conversation

brandontruggles
Copy link
Contributor

For Issue #6109. I updated the default value of aria-current on NavLink to "page". I also added "false" as a valid option, as defined in the spec for aria-current.

Also included are updated tests for NavLink, to reflect the above changes. The tests pass when I run npm run test in the root directory.

Please let me know if any further changes need to be made for this PR. If any documentation for NavLink needs to be changed, please send me a link to the locations that need to be modified, and I will update them accordingly. Thank you!

… the default value 'page' instead of 'true'.
@@ -67,13 +67,14 @@ NavLink.propTypes = {
"location",
"date",
"time",
"true"
"true",
"false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this now, I think that false shouldn't actually be included because this prop defines what is set when the <NavLink> is active, and aria-current=false indicates when it is not.

I am wondering if the default value when the <NavLink> isn't active should be changed. Currently it is set to null, but from the w3 spec I think maybe we should be setting it to false.

If the attribute is not present or its value is an empty string or undefined, the default value of false applies

It wouldn't really affect what is rendered because a null prop isn't included in the node's attributes, so it is just a matter of how explicit aria-current should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pshrmn Looking at the implementation of this...is there ever a time where any of the above values are used other than true?

If you take a look at the following line, where aria-current is passed to Link, the value only ever evaluates to true or null: https://github.com/ReactTraining/react-router/blob/233e6c51c047f1dc4e1cbabc48e7935a2a2b9d64/packages/react-router-dom/modules/NavLink.js#L45

Doesn't this mean that no matter what value is passed to ariaCurrent in NavLink (other than false), that the same value of true will be used regardless? This would mean that making "page" the default option would make no difference in the actual DOM property of the underlying link. Am I missing something? Is this intentional?

I think we can keep null as the default value, as the default value of aria-current on the underlying DOM link will be false when no aria-current property is explicity passed to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isActive && ariaCurrent uses the value of ariaCurrent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandonrninefive The boolean logic is a shortcut to a longer ternary (or even longer if/else). If isActive is true, then the result will be the value of ariaCurrent. It doesn't convert it to a binary.

Another neat fact is that the second value in a && pair won't be evaluated if the first is false, resulting in some possible performance optimization by avoiding expensive operations (e.g., !isCached && populateCache())

But I think the problem here is the string "false" vs the actual boolean typed value of false. The spec refers to the boolean, even though you can use quotes to make it a string too. It's weird and subtle. Fortunately, since we have React handling things for us, we can leave this out and let it deal with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timdorr Ah, I did not know about that shorthand for the ternary operator. Thank you for the info! If there's anything else needed for this PR, just let me know!

@timdorr timdorr merged commit 2d3c68b into remix-run:master May 8, 2018
@brandontruggles brandontruggles deleted the navlink-aria-current branch May 24, 2018 23:41
bors bot added a commit to mozilla/delivery-console that referenced this pull request Jun 6, 2018
179: Update dependency react-router-dom to v4.3.0 r=magopian a=renovate[bot]

This Pull Request updates dependency [react-router-dom](https://github.com/ReactTraining/react-router) from `v4.2.2` to `v4.3.0`



<details>
<summary>Release Notes</summary>

### [`v4.3.0`](https://github.com/ReactTraining/react-router/blob/master/CHANGELOG.md#v430httpsgithubcomReactTrainingreact-routercomparev420v430)
[Compare Source](remix-run/react-router@v4.3.0-rc.3...a27bc56)
> Jun 6, 2018

* Use the `pretty` option in generatePath ([#&#8203;6172] by @&#8203;sibelius)
* aria-current has incorrect value "true" ([#&#8203;6118] by @&#8203;brandonrninefive)
* Redirect with parameters ([#&#8203;5209] by @&#8203;dlindenkreuz)
* Fix with missing pathname: `<Link to="?foo=bar">` ([#&#8203;5489] by @&#8203;pshrmn)
* Escape NavLink path to allow special characters in path. ([#&#8203;5596] by @&#8203;esiegel)
* Expose `generatePath` ([#&#8203;5661] by @&#8203;rybon)
* Use named import of history module. ([#&#8203;5589] by @&#8203;RoboBurned)
* Hoist dependencies for smaller UMD builds ([#&#8203;5720] by @&#8203;pshrmn)
* Remove aria-current from navLink when inactive ([#&#8203;5508] by @&#8203;AlmeroSteyn)
* Add invariant for missing "to" property on `<Link>` ([#&#8203;5792] by @&#8203;selbekk)
* Use Prettier on the code ([e6f9017] by @&#8203;mjackson)
* Fix pathless route's match when parent is null ([#&#8203;5964] by @&#8203;pshrmn)
* Use history.createLocation in `<StaticRouter>` ([#&#8203;5722] by @&#8203;pshrmn)

[#&#8203;6172]: `remix-run/react-router#6172
[#&#8203;6118]: `remix-run/react-router#6118
[#&#8203;5209]: `remix-run/react-router#5209
[#&#8203;5489]: `remix-run/react-router#5489
[#&#8203;5596]: `remix-run/react-router#5596
[#&#8203;5661]: `remix-run/react-router#5661
[#&#8203;5589]: `remix-run/react-router#5589
[#&#8203;5720]: `remix-run/react-router#5720
[#&#8203;5508]: `remix-run/react-router#5508
[#&#8203;5792]: `remix-run/react-router#5792
[e6f9017]: remix-run/react-router@e6f9017
[#&#8203;5964]: `remix-run/react-router#5964
[#&#8203;5722]: `remix-run/react-router#5722

---

### [`v4.3.0-rc.3`](https://github.com/ReactTraining/react-router/releases/v4.3.0-rc.3)
[Compare Source](remix-run/react-router@v4.3.0-rc.2...v4.3.0-rc.3)
- Fix broken UMD builds.
- Add sideEffects: false for webpack tree shaking (#&#8203;6082 by @&#8203;taylorc93)

---

### [`v4.3.0-rc.2`](https://github.com/ReactTraining/react-router/releases/v4.3.0-rc.2)
[Compare Source](remix-run/react-router@v4.3.0-rc.1...v4.3.0-rc.2)
- Bump `hoist-non-react-statics` for React 16.3.
- Missing `generatePath` in `react-router-dom` package.

---

### [`v4.3.0-rc.1`](https://github.com/ReactTraining/react-router/releases/v4.3.0-rc.1)
[Compare Source](remix-run/react-router@v4.2.2...v4.3.0-rc.1)
> Mar 26, 2018

- Redirect with parameters ([#&#8203;5209] by @&#8203;dlindenkreuz)
- Fix with missing pathname: `<Link to="?foo=bar">` ([#&#8203;5489] by @&#8203;pshrmn)
- Escape NavLink path to allow special characters in path. ([#&#8203;5596] by @&#8203;esiegel)
- Expose `generatePath` ([#&#8203;5661] by @&#8203;rybon)
- Use named import of history module. ([#&#8203;5589] by @&#8203;RoboBurned)
- Hoist dependencies for smaller UMD builds ([#&#8203;5720] by @&#8203;pshrmn)
- Remove aria-current from navLink when inactive ([#&#8203;5508] by @&#8203;AlmeroSteyn)
- Add invariant for missing "to" property on `<Link>` ([#&#8203;5792] by @&#8203;selbekk)
- Use Prettier on the code ([e6f9017] by @&#8203;mjackson)
- Fix pathless route's match when parent is null ([#&#8203;5964] by @&#8203;pshrmn)
- Use history.createLocation in `<StaticRouter>` ([#&#8203;5722] by @&#8203;pshrmn)

[#&#8203;5209]: `remix-run/react-router#5209
[#&#8203;5489]: `remix-run/react-router#5489
[#&#8203;5596]: `remix-run/react-router#5596
[#&#8203;5661]: `remix-run/react-router#5661
[#&#8203;5589]: `remix-run/react-router#5589
[#&#8203;5720]: `remix-run/react-router#5720
[#&#8203;5508]: `remix-run/react-router#5508
[#&#8203;5792]: `remix-run/react-router#5792
[e6f9017]: remix-run/react-router@e6f9017
[#&#8203;5964]: `remix-run/react-router#5964
[#&#8203;5722]: `remix-run/react-router#5722

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).

Co-authored-by: Renovate Bot <bot@renovateapp.com>
bors bot added a commit to mozilla/delivery-console that referenced this pull request Jun 6, 2018
178: Update dependency react-router to v4.3.0 r=magopian a=renovate[bot]

This Pull Request updates dependency [react-router](https://github.com/ReactTraining/react-router) from `v4.2.0` to `v4.3.0`



<details>
<summary>Release Notes</summary>

### [`v4.3.0`](https://github.com/ReactTraining/react-router/blob/master/CHANGELOG.md#v430httpsgithubcomReactTrainingreact-routercomparev420v430)
[Compare Source](remix-run/react-router@v4.3.0-rc.3...v4.3.0)
> Jun 6, 2018

* Use the `pretty` option in generatePath ([#&#8203;6172] by @&#8203;sibelius)
* aria-current has incorrect value "true" ([#&#8203;6118] by @&#8203;brandonrninefive)
* Redirect with parameters ([#&#8203;5209] by @&#8203;dlindenkreuz)
* Fix with missing pathname: `<Link to="?foo=bar">` ([#&#8203;5489] by @&#8203;pshrmn)
* Escape NavLink path to allow special characters in path. ([#&#8203;5596] by @&#8203;esiegel)
* Expose `generatePath` ([#&#8203;5661] by @&#8203;rybon)
* Use named import of history module. ([#&#8203;5589] by @&#8203;RoboBurned)
* Hoist dependencies for smaller UMD builds ([#&#8203;5720] by @&#8203;pshrmn)
* Remove aria-current from navLink when inactive ([#&#8203;5508] by @&#8203;AlmeroSteyn)
* Add invariant for missing "to" property on `<Link>` ([#&#8203;5792] by @&#8203;selbekk)
* Use Prettier on the code ([e6f9017] by @&#8203;mjackson)
* Fix pathless route's match when parent is null ([#&#8203;5964] by @&#8203;pshrmn)
* Use history.createLocation in `<StaticRouter>` ([#&#8203;5722] by @&#8203;pshrmn)

[#&#8203;6172]: `remix-run/react-router#6172
[#&#8203;6118]: `remix-run/react-router#6118
[#&#8203;5209]: `remix-run/react-router#5209
[#&#8203;5489]: `remix-run/react-router#5489
[#&#8203;5596]: `remix-run/react-router#5596
[#&#8203;5661]: `remix-run/react-router#5661
[#&#8203;5589]: `remix-run/react-router#5589
[#&#8203;5720]: `remix-run/react-router#5720
[#&#8203;5508]: `remix-run/react-router#5508
[#&#8203;5792]: `remix-run/react-router#5792
[e6f9017]: remix-run/react-router@e6f9017
[#&#8203;5964]: `remix-run/react-router#5964
[#&#8203;5722]: `remix-run/react-router#5722

---

### [`v4.3.0-rc.3`](https://github.com/ReactTraining/react-router/releases/v4.3.0-rc.3)
[Compare Source](remix-run/react-router@v4.3.0-rc.2...v4.3.0-rc.3)
- Fix broken UMD builds.
- Add sideEffects: false for webpack tree shaking (#&#8203;6082 by @&#8203;taylorc93)

---

### [`v4.3.0-rc.2`](https://github.com/ReactTraining/react-router/releases/v4.3.0-rc.2)
[Compare Source](remix-run/react-router@v4.3.0-rc.1...v4.3.0-rc.2)
- Bump `hoist-non-react-statics` for React 16.3.
- Missing `generatePath` in `react-router-dom` package.

---

### [`v4.3.0-rc.1`](https://github.com/ReactTraining/react-router/releases/v4.3.0-rc.1)
[Compare Source](remix-run/react-router@v4.2.0...v4.3.0-rc.1)
> Mar 26, 2018

- Redirect with parameters ([#&#8203;5209] by @&#8203;dlindenkreuz)
- Fix with missing pathname: `<Link to="?foo=bar">` ([#&#8203;5489] by @&#8203;pshrmn)
- Escape NavLink path to allow special characters in path. ([#&#8203;5596] by @&#8203;esiegel)
- Expose `generatePath` ([#&#8203;5661] by @&#8203;rybon)
- Use named import of history module. ([#&#8203;5589] by @&#8203;RoboBurned)
- Hoist dependencies for smaller UMD builds ([#&#8203;5720] by @&#8203;pshrmn)
- Remove aria-current from navLink when inactive ([#&#8203;5508] by @&#8203;AlmeroSteyn)
- Add invariant for missing "to" property on `<Link>` ([#&#8203;5792] by @&#8203;selbekk)
- Use Prettier on the code ([e6f9017] by @&#8203;mjackson)
- Fix pathless route's match when parent is null ([#&#8203;5964] by @&#8203;pshrmn)
- Use history.createLocation in `<StaticRouter>` ([#&#8203;5722] by @&#8203;pshrmn)

[#&#8203;5209]: `remix-run/react-router#5209
[#&#8203;5489]: `remix-run/react-router#5489
[#&#8203;5596]: `remix-run/react-router#5596
[#&#8203;5661]: `remix-run/react-router#5661
[#&#8203;5589]: `remix-run/react-router#5589
[#&#8203;5720]: `remix-run/react-router#5720
[#&#8203;5508]: `remix-run/react-router#5508
[#&#8203;5792]: `remix-run/react-router#5792
[e6f9017]: remix-run/react-router@e6f9017
[#&#8203;5964]: `remix-run/react-router#5964
[#&#8203;5722]: `remix-run/react-router#5722

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).

Co-authored-by: Renovate Bot <bot@renovateapp.com>
@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants