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 HasMenuCurrent and IsDescendant/IsAncestor when comparing to itself #9926

Merged
merged 1 commit into from
May 28, 2022

Conversation

bep
Copy link
Member

@bep bep commented May 25, 2022

Fix HasMenuCurrent and IsDescendant/IsAncestor when comparing to itself

There may be sites in the wild that depends on the faulty behaviour of IsDescendant/IsAncestor when comparing to itself, but

  • The documentation and common sense says that a thing cannot be descendant or ancestor to itself.
  • The bug introduced in HasMenuCurrent comes directly from that confusion.

Fixes #9846

@bep
Copy link
Member Author

bep commented May 26, 2022

OK, this need some thinking, I notice we already reverted this in #7206 ...

But I don't think we can keep obviously wrong behaviour (which is not in line with the documentation) because it will break some themes. In my head the old behaviour can be had with:

{{ if or (eq $p1 $p2) ($p1.IsAncestor $p2) }}
{{ end }}

/cc @tekezo

@bep bep removed the request for review from jmooring May 26, 2022 11:25
There may be sites in the wild that depends on the faulty behaviour of IsDescendant/IsAncestor when comparing to itself, but

* The documentation and common sense says that a thing cannot be descendant or ancestor to itself.
* The bug introduced in `HasMenuCurrent` comes directly from that confusion.

Fixes gohugoio#9846
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2023
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.

Both HasMenuCurrent and IsMenuCurrent return true for section pages
1 participant