-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Fix for Issue #6109 - aria-current has incorrect value "true" #6118
Conversation
… the default value 'page' instead of 'true'.
@@ -67,13 +67,14 @@ NavLink.propTypes = { | |||
"location", | |||
"date", | |||
"time", | |||
"true" | |||
"true", | |||
"false" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
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 ([#​6172] by @​sibelius) * aria-current has incorrect value "true" ([#​6118] by @​brandonrninefive) * Redirect with parameters ([#​5209] by @​dlindenkreuz) * Fix with missing pathname: `<Link to="?foo=bar">` ([#​5489] by @​pshrmn) * Escape NavLink path to allow special characters in path. ([#​5596] by @​esiegel) * Expose `generatePath` ([#​5661] by @​rybon) * Use named import of history module. ([#​5589] by @​RoboBurned) * Hoist dependencies for smaller UMD builds ([#​5720] by @​pshrmn) * Remove aria-current from navLink when inactive ([#​5508] by @​AlmeroSteyn) * Add invariant for missing "to" property on `<Link>` ([#​5792] by @​selbekk) * Use Prettier on the code ([e6f9017] by @​mjackson) * Fix pathless route's match when parent is null ([#​5964] by @​pshrmn) * Use history.createLocation in `<StaticRouter>` ([#​5722] by @​pshrmn) [#​6172]: `https://github.com/ReactTraining/react-router/pull/6172` [#​6118]: `https://github.com/ReactTraining/react-router/pull/6118` [#​5209]: `https://github.com/ReactTraining/react-router/pull/5209` [#​5489]: `https://github.com/ReactTraining/react-router/pull/5489` [#​5596]: `https://github.com/ReactTraining/react-router/pull/5596` [#​5661]: `https://github.com/ReactTraining/react-router/pull/5661` [#​5589]: `https://github.com/ReactTraining/react-router/pull/5589` [#​5720]: `https://github.com/ReactTraining/react-router/pull/5720` [#​5508]: `https://github.com/ReactTraining/react-router/pull/5508` [#​5792]: `https://github.com/ReactTraining/react-router/pull/5792` [e6f9017]: remix-run/react-router@e6f9017 [#​5964]: `https://github.com/ReactTraining/react-router/pull/5964` [#​5722]: `https://github.com/ReactTraining/react-router/pull/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 (#​6082 by @​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 ([#​5209] by @​dlindenkreuz) - Fix with missing pathname: `<Link to="?foo=bar">` ([#​5489] by @​pshrmn) - Escape NavLink path to allow special characters in path. ([#​5596] by @​esiegel) - Expose `generatePath` ([#​5661] by @​rybon) - Use named import of history module. ([#​5589] by @​RoboBurned) - Hoist dependencies for smaller UMD builds ([#​5720] by @​pshrmn) - Remove aria-current from navLink when inactive ([#​5508] by @​AlmeroSteyn) - Add invariant for missing "to" property on `<Link>` ([#​5792] by @​selbekk) - Use Prettier on the code ([e6f9017] by @​mjackson) - Fix pathless route's match when parent is null ([#​5964] by @​pshrmn) - Use history.createLocation in `<StaticRouter>` ([#​5722] by @​pshrmn) [#​5209]: `https://github.com/ReactTraining/react-router/pull/5209` [#​5489]: `https://github.com/ReactTraining/react-router/pull/5489` [#​5596]: `https://github.com/ReactTraining/react-router/pull/5596` [#​5661]: `https://github.com/ReactTraining/react-router/pull/5661` [#​5589]: `https://github.com/ReactTraining/react-router/pull/5589` [#​5720]: `https://github.com/ReactTraining/react-router/pull/5720` [#​5508]: `https://github.com/ReactTraining/react-router/pull/5508` [#​5792]: `https://github.com/ReactTraining/react-router/pull/5792` [e6f9017]: remix-run/react-router@e6f9017 [#​5964]: `https://github.com/ReactTraining/react-router/pull/5964` [#​5722]: `https://github.com/ReactTraining/react-router/pull/5722` --- </details> --- This PR has been generated by [Renovate Bot](https://renovatebot.com). Co-authored-by: Renovate Bot <[email protected]>
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 ([#​6172] by @​sibelius) * aria-current has incorrect value "true" ([#​6118] by @​brandonrninefive) * Redirect with parameters ([#​5209] by @​dlindenkreuz) * Fix with missing pathname: `<Link to="?foo=bar">` ([#​5489] by @​pshrmn) * Escape NavLink path to allow special characters in path. ([#​5596] by @​esiegel) * Expose `generatePath` ([#​5661] by @​rybon) * Use named import of history module. ([#​5589] by @​RoboBurned) * Hoist dependencies for smaller UMD builds ([#​5720] by @​pshrmn) * Remove aria-current from navLink when inactive ([#​5508] by @​AlmeroSteyn) * Add invariant for missing "to" property on `<Link>` ([#​5792] by @​selbekk) * Use Prettier on the code ([e6f9017] by @​mjackson) * Fix pathless route's match when parent is null ([#​5964] by @​pshrmn) * Use history.createLocation in `<StaticRouter>` ([#​5722] by @​pshrmn) [#​6172]: `https://github.com/ReactTraining/react-router/pull/6172` [#​6118]: `https://github.com/ReactTraining/react-router/pull/6118` [#​5209]: `https://github.com/ReactTraining/react-router/pull/5209` [#​5489]: `https://github.com/ReactTraining/react-router/pull/5489` [#​5596]: `https://github.com/ReactTraining/react-router/pull/5596` [#​5661]: `https://github.com/ReactTraining/react-router/pull/5661` [#​5589]: `https://github.com/ReactTraining/react-router/pull/5589` [#​5720]: `https://github.com/ReactTraining/react-router/pull/5720` [#​5508]: `https://github.com/ReactTraining/react-router/pull/5508` [#​5792]: `https://github.com/ReactTraining/react-router/pull/5792` [e6f9017]: remix-run/react-router@e6f9017 [#​5964]: `https://github.com/ReactTraining/react-router/pull/5964` [#​5722]: `https://github.com/ReactTraining/react-router/pull/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 (#​6082 by @​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 ([#​5209] by @​dlindenkreuz) - Fix with missing pathname: `<Link to="?foo=bar">` ([#​5489] by @​pshrmn) - Escape NavLink path to allow special characters in path. ([#​5596] by @​esiegel) - Expose `generatePath` ([#​5661] by @​rybon) - Use named import of history module. ([#​5589] by @​RoboBurned) - Hoist dependencies for smaller UMD builds ([#​5720] by @​pshrmn) - Remove aria-current from navLink when inactive ([#​5508] by @​AlmeroSteyn) - Add invariant for missing "to" property on `<Link>` ([#​5792] by @​selbekk) - Use Prettier on the code ([e6f9017] by @​mjackson) - Fix pathless route's match when parent is null ([#​5964] by @​pshrmn) - Use history.createLocation in `<StaticRouter>` ([#​5722] by @​pshrmn) [#​5209]: `https://github.com/ReactTraining/react-router/pull/5209` [#​5489]: `https://github.com/ReactTraining/react-router/pull/5489` [#​5596]: `https://github.com/ReactTraining/react-router/pull/5596` [#​5661]: `https://github.com/ReactTraining/react-router/pull/5661` [#​5589]: `https://github.com/ReactTraining/react-router/pull/5589` [#​5720]: `https://github.com/ReactTraining/react-router/pull/5720` [#​5508]: `https://github.com/ReactTraining/react-router/pull/5508` [#​5792]: `https://github.com/ReactTraining/react-router/pull/5792` [e6f9017]: remix-run/react-router@e6f9017 [#​5964]: `https://github.com/ReactTraining/react-router/pull/5964` [#​5722]: `https://github.com/ReactTraining/react-router/pull/5722` --- </details> --- This PR has been generated by [Renovate Bot](https://renovatebot.com). Co-authored-by: Renovate Bot <[email protected]>
For Issue #6109. I updated the default value of
aria-current
onNavLink
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 runnpm 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!