[NTH - FE] Keep subsection competency pills inside their cards at narrow widths

Đang mở Phù hợp với người mới
#942 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, scss, typescript
Lĩnh vực
accessibility, frontend

Hướng nghiên cứu

Bắt đầu với src/taxonomy/competency-management/course-search/CourseOutlineSubtree.tsx và CourseSearchBrowse.scss, nơi issue xác định kiểu hàng và pill của các tiểu mục. Kiểm tra các quy tắc hiện có cho tiêu đề khóa học và mục, sau đó xem dàn ý ở 375px và khi cột khóa học trên desktop được thu hẹp. Công việc hoàn tất khi các pill nằm gọn trong thẻ, ID dài được rút gọn nhưng vẫn có nhãn đầy đủ cho trình đọc màn hình, và ID ngắn nằm cạnh tên tiểu mục khi còn đủ chỗ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

User Story

As a course author working in a narrow window, I want each subsection's competency pill to stay inside its card, in order to read the subsection name and use the associate button without anything spilling off the edge.

Description

In the Courses & Content panel, each graded subsection card shows its competency pill to the right of the subsection name. At phone width (375px), or when the course column is dragged narrow on desktop, the pill sticks out past the card and the name runs into it. The pill should drop below the name when the two don't fit side by side, and a competency ID that's still too long should be shortened with an ellipsis.

Context

UX Design

No Figma frame for the narrow case yet. The Acceptance Criteria describe the layout.

  • Screenshot of the current overflow at 375px:
image

Acceptance Criteria

Scenario: Pills stay inside their cards at phone width
  Given Competency Management at a 375px wide viewport
  And a selected competency with a long external ID, such as "Oral Communication"
  When I expand a course and a section that has graded subsections
  Then every subsection's pill sits inside its card
  And the page does not scroll sideways

Scenario: A wide card keeps the pill beside the name
  Given a desktop-width viewport and a selected competency with a short external ID, such as "CCRS-1.3"
  When I expand a course and a section that has graded subsections
  Then each subsection's pill sits on the same line as its name, aligned to the right of the card

Scenario: A narrow card moves the pill below the name
  Given a subsection card too narrow to fit its name and its pill side by side
  When I view that subsection
  Then the pill sits on its own line below the name
  And the name wraps onto more lines without overlapping the pill

Scenario: An ID too long for the card is shortened inside the pill
  Given a selected competency whose external ID is wider than the subsection card
  When I view a subsection's applied or associate pill
  Then the ID ends in an ellipsis inside the pill
  And the competency icon, and the add icon on an associate pill, stay fully visible

Scenario: Screen readers still get the full ID
  Given a subsection pill whose ID is shortened with an ellipsis
  When a screen reader reads the associate button or the applied pill
  Then it announces the full external ID

Scenario: A narrow course column at desktop width
  Given a desktop-width viewport
  And the divider between the competency tree and the course column dragged as far right as it goes
  When I expand a course and a section that has graded subsections
  Then every subsection's pill sits inside its card
Technical Details

This is a suggested approach, not the source of truth. The User Story, Description, and Acceptance Criteria define what must be true when the work is done.

Approach

SubsectionRow in CourseOutlineSubtree.tsx renders the card as one non-wrapping flex row (d-flex align-items-center justify-content-between) of an unstyled name <span> and the pill. The pill has flex-shrink: 0 and no max-width, the ID isn't truncated, and the name keeps the flex default min-width: auto, so neither can give way.

  1. On &__subsection, add flex-wrap: wrap and a gap (spacer 1 vertical, spacer 2 horizontal), so the pill can drop to a second line with space around it.
  2. Give the name span a new &__subsection-title class with flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere. The 10rem basis decides the wrap: the pill stays beside the name while the name gets at least 10rem, and drops below it otherwise.
  3. On &__subsection-pill, keep flex-shrink: 0 and add min-width: 0; max-width: 100%. Keep the pill's icons and &__subsection-pill-divider at flex-shrink: 0; match the icon selectors to the rendered DOM of CompetencyIcon and Paragon's Icon.
  4. On &__subsection-pill-id, add min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap. The associate button's aria-label and the applied pill's sr-only text already carry the full ID, so only the visible text is cut.
  5. The blocked pill from https://github.com/openedx/frontend-app-authoring/pull/3376 shares these classes and needs no separate change.
  6. jsdom doesn't do layout, so check the scenarios in a browser at 375px, at desktop with the divider dragged right, and with a 40-character ID with no spaces.

Files to create and modify

File Change
src/taxonomy/competency-management/course-search/CourseSearchBrowse.scss modified: wrap and gap on the row, new title class, pill and ID truncation
src/taxonomy/competency-management/course-search/CourseOutlineSubtree.tsx modified: title class on the subsection name span

Additional context

  • &__course-title and &__section-title in CourseSearchBrowse.scss already use min-width: 0 and overflow-wrap: anywhere for long titles in the same outline.
  • The "Demonstrate mastery for" heading at the top of the same column (CriteriaAssociationsSection.tsx) already truncates the competency name and its ID badge (.competency-row__badge with text-truncate) with an ellipsis.
Ngôn ngữ chính
Python
Star
10
Fork
35
Merge trung bình
4 ngày 14 giờ
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openedx/openedx-core

Tất cả issue của openedx/openedx-core

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.