Skip to content

Commit 4ded389

Browse files
hsbtclaude
andcommitted
Disable Back and Next at the ends of the tutorial
Both stayed clickable on the first and last steps and silently did nothing there. #155 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 72e7221 commit 4ded389

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎app/try_ruby.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ def update_screen(item)
381381
step = item.step.to_s
382382
$document.at_css("#tryruby-index").value = step
383383

384+
# Disable the buttons that have no step to go to
385+
$document.at_css('#btn_back').disabled = !@items.has_key?(item.step - 1)
386+
$document.at_css('#btn_next').disabled = !@items.has_key?(item.step + 1)
387+
384388
# Set session cookie to store progress
385389
set_cookie('tryruby_step', step)
386390

‎spec/tutorial_spec.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
special = steps[step] || {}
5151

5252
find(:css, "h1").text.should be == data["title"]
53+
page.should have_button("Back", disabled: step == 1)
54+
page.should have_button("Next", disabled: step == 56)
5355

5456
unless special[:pass]
5557
case special[:code]

0 commit comments

Comments
 (0)