Skip to content

Feature: Replace lesson View Course button with Previous Lesson#5328

Open
KevinMulhern wants to merge 1 commit into
mainfrom
feature/previous-lesson-button
Open

Feature: Replace lesson View Course button with Previous Lesson#5328
KevinMulhern wants to merge 1 commit into
mainfrom
feature/previous-lesson-button

Conversation

@KevinMulhern
Copy link
Copy Markdown
Member

Because:
With the new course-contents sidebar on the lesson page providing a "Back to course" link on both mobile and desktop, the View Course button at the bottom of the lesson was redundant. Swapping it for a Previous Lesson button gives users a natural pair with the existing Next Lesson button for sequential navigation through a course.

Closes: #2623

This PR:

  • Adds Course#previous_lesson and refactors Course#next_lesson to share the same range-based query style
  • Replaces the "View Course" button in app/views/lessons/_lesson_buttons.html.erb with a conditional Previous Lesson button that is hidden on the first lesson
  • Reworks the lesson button row from flex justify-between to a 3-column grid on md+ so Complete stays centered and Previous/Next stay anchored to the row edges regardless of which neighbours render; mobile keeps the existing full-width stacked layout via display: contents on the slot wrappers

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the redundant “View Course” button at the bottom of lesson pages with a “Previous Lesson” button to improve sequential navigation (pairing with the existing “Next Lesson” button), supported by new Course#previous_lesson behavior and related UI/test updates.

Changes:

  • Add Course#previous_lesson and refactor Course#next_lesson to use range-based queries.
  • Update lesson button UI to conditionally render Previous/Next and switch md+ layout to a 3-column grid while preserving the mobile stacked layout.
  • Update system specs to validate Previous Lesson navigation behavior and add model specs for previous_lesson.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
app/models/course.rb Introduces previous_lesson and refactors next_lesson query approach.
app/views/lessons/_lesson_buttons.html.erb Replaces “View Course” with conditional “Previous Lesson” and updates responsive layout.
spec/system/lesson_navigation_spec.rb Replaces View Course system test with Previous Lesson navigation coverage.
spec/models/course_spec.rb Adds unit coverage for Course#previous_lesson.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/models/course.rb Outdated
Comment thread app/models/course.rb Outdated
Comment thread app/views/lessons/_lesson_buttons.html.erb
Comment thread app/views/lessons/_lesson_buttons.html.erb
Comment thread spec/system/lesson_navigation_spec.rb Outdated
Comment thread spec/models/course_spec.rb
@KevinMulhern KevinMulhern force-pushed the feature/previous-lesson-button branch from d8ebbe7 to 79e0a75 Compare May 19, 2026 07:45
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-5328 May 19, 2026 07:46 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/previous-lesson-button branch from 79e0a75 to e206061 Compare May 19, 2026 08:03
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-5328 May 19, 2026 08:04 Inactive
@KevinMulhern KevinMulhern force-pushed the feature/previous-lesson-button branch from e206061 to b21922a Compare May 19, 2026 08:06
@KevinMulhern KevinMulhern temporarily deployed to odin-review-app-pr-5328 May 19, 2026 08:06 Inactive
@KevinMulhern KevinMulhern requested a review from Copilot May 19, 2026 08:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread app/models/course.rb
Comment on lines +1 to +4
<div class="flex flex-col gap-y-6 max-w-sm mx-auto md:grid md:grid-cols-3 md:gap-x-7 md:gap-y-0 md:max-w-full md:items-center">
<% if course.previous_lesson(lesson).present? %>
<div class="contents md:block md:justify-self-start">
<%= link_to lesson_path(course.previous_lesson(lesson)), class: 'button button--secondary px-4 py-2 font-medium', data: { test_id: 'previous-lesson-btn' } do %>
Comment thread spec/system/lesson_navigation_spec.rb
Because:
With the new course-contents sidebar on the lesson page providing a
"Back to course" link on both mobile and desktop, the View Course
button at the bottom of the lesson was redundant. Swapping it for a
Previous Lesson button gives users a natural pair with the existing
Next Lesson button for sequential navigation through a course.

This PR:
- Adds Course#previous_lesson and refactors Course#next_lesson to share the same range-based query style
- Replaces the "View Course" button in app/views/lessons/_lesson_buttons.html.erb with a conditional Previous Lesson button that is hidden on the first lesson
- Reworks the lesson button row from `flex justify-between` to a 3-column grid on md+ so Complete stays centered and Previous/Next stay anchored to the row edges regardless of which neighbours render; mobile keeps the existing full-width stacked layout via `display: contents` on the slot wrappers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋 Backlog / Ideas

Development

Successfully merging this pull request may close these issues.

Implementation of "Previous Lesson" button

2 participants