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

Plugins: FAQ: Restore anchors to FAQ items #315

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

dd32
Copy link
Member

@dd32 dd32 commented May 10, 2024

The FAQ anchors have ceased to update the URI, this PR attempts to add it back.

TODO: The scrollTo functionality doesn't work, it triggers, but it's like some other JS from something else forces a scroll to the top of the page instantly.

@StevenDufresne Do you wish to take this over?

@dd32 dd32 requested a review from StevenDufresne May 10, 2024 03:06
@StevenDufresne
Copy link
Contributor

This is working for me?

https://d.pr/i/lSTkLy

@ryelle
Copy link
Contributor

ryelle commented May 10, 2024

The URL update is working if you click the button, but not elsewhere in the dt, despite anywhere in the dt opening the question.

Screenshot 2024-05-10 at 3 08 36 PM

I also see an issue with some questions working while others don't, and I wonder if it has to do with punctuation (apostrophes in particular)— "Q: Can I customize the booking calendar colors?" works, but "Q: The booking calendar form doesn’t appear. Solution?" does not.

Removing the action from the button will likely break the keyboard functionality here. Also, it looks like this also needs focus states.

@dd32 dd32 force-pushed the fix/plugins-faq-anchors branch from f5abe0a to 99515ac Compare May 15, 2024 02:55
@dd32
Copy link
Member Author

dd32 commented May 15, 2024

The URL update is working if you click the button

Ahhhh, yeah I've never clicked the button.. always the h3 or dt.

Removing the action from the button will likely break the keyboard functionality here.

I've tested it, and keyboard appears to still work fine.

The formaction is missing the leading # so it's currently reliant upon the JS click handler to work.

The FAQ items also have zero focus state for keyboard navigation, so it's impossible to tell which element the keyboard is focused on right now.

I also see an issue with some questions working while others don't, and I wonder if it has to do with punctuation (apostrophes in particular)

Yep, that's caused by ' in the question. Javascript EncodeURI() and EncodeURIComponent both never encode -.!~*'() characters, but PHP does. These characters are "unreserved marks" that can be used in URLs unencoded without concern, but PHP encodes them for good measure.

That causes the following line to never find an element, since ' != %27

document.getElementById( encodeURIComponent( decodeURIComponent( window.location.hash.substr(1) ).trim() ) )

This includes a JS function for RFC3986 encoding, which would encode those characters, but that also doesn't encode[] which PHP still does for the before-mentioned functions.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI#encoding_for_rfc3986

13a3418 should resolve that.. even if it looks a bit complicated..

bazza pushed a commit that referenced this pull request May 28, 2024
See: #315
Props: dd32, ryelle


git-svn-id: https://meta.svn.wordpress.org/sites/trunk@13750 74240141-8908-4e6f-9713-ba540dce6ec7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants