Demo app should degrade better without JS · Issue #680 · unpoly/unpoly · GitHub
Skip to content

Demo app should degrade better without JS #680

Open

Description

@bdavidxyz

Bug description

Hello there, I just "git cloned" the unpoly demo (Rails), and launched it on my computer, everything works properly.

Then I was curious : what if I remove entirely the JS? so I removed <%= javascript_include_tag 'application', defer: true %>
from the app layout.

From what I understand, "progressive enhancement" means the app should work even if the JS is not there.

When I click on "toggle done" for a task, a 500 error arise :

Started GET "/tasks/21/toggle_done" for ::1 at 2024-11-22 21:44:04 +0100
ActionController::RoutingError (No route matches [GET] "/tasks/21/toggle_done"):

Reproduction project

Very minimalist step to reproduce, just clone the demo and remove the JS from the app layout

Steps to reproduce the behavior:

  1. git clone unpoly/unpoly-demo (rails version)
  2. bundle install
  3. go to app/views/layouts/application.erb and remove <%= javascript_include_tag 'application', defer: true %>
  4. bin/rails s
  5. Go to tasks list, and click on "done" on one of the task.
  6. Bug

Expected behavior

if I understand correctly, I should see a toggled task, and no bug

Browser version

  • OS: Linux Mint
  • Browser Chrome - Version 131

Additional context

I think that's all. Many thanks for this lib BTW!

Activity

  1. changed the title [-]Fully remove JS in the demo[/-] [+]Demo app should degrade better without JS[/+] on Nov 25, 2024
  2. triskweline commented on Nov 25, 2024

    @triskweline
    Contributor

    Unpoly also makes an effort to design features in a way that there's a fallback story without JS for every feature. This will usually additional testing by the app developer, and developers may themselves decide whether to care about this use case.

    I didn't test without JS for the demo because I wanted to show off the enhancements. Maybe after the 3.10 release I can make a pass over the demo code to ensure basic functionality remains available without JS.

    click on "done" on one of the task.
    When I click on "toggle done" for a task, a 500 error arise

    These are links to make POST or PATCH requests. I was lazy and used an a[data-method], because that was easier for me to style, at the cost of requiring JavaScript. Rails actually comes with a button_to helper that produces non-GET-buttons by rendering a small form with a <input type="hidden" name="method" value="patch">, which works without JS.

  3. bdavidxyz commented on Nov 25, 2024

    @bdavidxyz
    Author

    Ok! I was wondering why we don't see more often this "form/button" pattern, but now this make sense. BTW thanks a ton @triskweline for this incredible project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions