question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug or potential issue - show-hide-content.js

See original GitHub issue

Hi,

Following up from a discussion with @dsingleton on XGOV Slack. I noticed a slight issue with the show-hide-content.js code.

If you examine line 83 you will see there is an assumption that the ‘Conditionally revealing content’ pattern will existing within a form element.

As I was quickly hacking together a prototype within the the govuk prototyping kit, I hadn’t wrapped the markup in a form element and it broke silently (no errors or console warnings). It’s an edge case but as there is now a firm movement toward modular builds of components this could bite people.

Simple short term suggestion, check for existence of a form element, else console log a developer friendly message.

Longer term, assume this will be replaced by what’s delivered in GOVUK Front-end?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
robinwhittletoncommented, Jan 11, 2017

Yes. Imagine a situation where you have two sets of radios with the same name attributes. Outside of a form or within the same form they’ll share the selected state toggling behaviour. In two seperate forms they’ll maintain two seperate toggle states.

0reactions
paulmsmithcommented, Feb 1, 2017

Nice. +1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with section show and hide with javascript code not ...
1 Answer 1 · document.querySelector("#fullpage section:nth-child("+page")"); Is not valid. · @SølveTornøe he is missing a lot more in his code ..
Read more >
How to hide and show initial content, depending on whether ...
The solution is to include a JavaScript file in the head part of the document. If JavaScript is enabled, it directly runs an...
Read more >
Lesson 5: Using Javascript to Hide and Show Content
One way that JavaScript is commonly used is to hide or display content based on user behavior. For example, a user may select...
Read more >
JavaScript · Bootstrap
Usage. Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .open class on the parent list ......
Read more >
Handling common JavaScript problems - MDN Web Docs
As with HTML and CSS, you can ensure better quality, less error-prone JavaScript code using a linter, which points out errors and can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found