spiffy-navigation icon indicating copy to clipboard operation
spiffy-navigation copied to clipboard

Correct isActive when default params are set

Open maxnuf opened this issue 10 years ago • 5 comments

I don't really understand the logic of paramsAreEqual. When default parameters where set, none of my navigation was active. The logic used in Zend/Navigation/Page/Mvc works fine for me.

maxnuf avatar Jun 23 '14 21:06 maxnuf

Coverage Status

Coverage decreased (-0.13%) when pulling d2238f7c514c761c4ddf1b74b31da68ad07178bf on maxnuf:default_param into 6599c515be8ffc8042d7db91bebcc12637e9d3c1 on spiffyjr:master.

coveralls avatar Jun 23 '14 21:06 coveralls

Can you rebase this with master?

spiffyjr avatar Jun 26 '14 18:06 spiffyjr

I will, but it conflicts with PR #25

it feels like the tests are trying to accomplish something different then they should.

maxnuf avatar Jun 28 '14 10:06 maxnuf

Come to think of it, my PR should solve the use case in PR #25 too. There is no need to add ignore_params to the navigation. Nor should you want to.

Test testIsActiveWithIgnoringParamRecursion is in essence similar to the test I gave.

  • There is a matched route with a param (could be an optional param, or could be default).
  • In navigation we have a link to that route (no param provided)
  • It should be active.

In that light, I think testIsActiveWithoutIgnoringParamRecursion is faulty. If you don't want the nav link to be active, you should provide the correct param for it.

...
  'page' => array(
    'pages' => array(
      'child'=> array(
        'options' => array(
          'route' => 'test',
          'id' => 20,
    ...

And if you do want it to match (for any id found in the matched route), don't set the id in navigation config.

@dready thoughts?

maxnuf avatar Jun 28 '14 12:06 maxnuf

I saw his PR first which is why I merged it but I like this solution more.

spiffyjr avatar Jun 30 '14 13:06 spiffyjr