Skip to content

feat(table): introduce recent active markers #3516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

paulinewahle
Copy link
Contributor

@paulinewahle paulinewahle commented Apr 2, 2025

fix: https://github.com/Lundalogik/crm-feature/issues/1294

Summary by CodeRabbit

  • New Features
    • Enhanced table interactions with clear visual indicators for recently active rows.
    • Implemented a history tracking system for row selections, providing intuitive and dynamic feedback during table usage.

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

@paulinewahle paulinewahle self-assigned this Apr 2, 2025
@Copilot Copilot AI review requested due to automatic review settings April 2, 2025 13:29
Copy link

coderabbitai bot commented Apr 2, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a visual enhancement and an active row tracking feature. A new CSS class .recent-active is added with a pseudo-element that provides a visual indicator for recently active rows. Simultaneously, the Table component is modified to maintain an active row history through a new private property and a static constant limiting the history size. The row click handler now manages this history, and the row formatting logic applies the new .recent-active class to eligible rows.

Changes

File Change Summary
src/.../tabulator-custom-styles.scss Added a new .recent-active class with a nested :before pseudo-element specifying dimensions, border, sticky positioning, z-index, and inset adjustments for visual feedback on recent activity.
src/.../table.tsx Introduced private property activeRowHistory and static constant MAX_ACTIVE_ROW_HISTORY (set to 2). Updated onClickRow to manage row history and modified formatRow to conditionally apply the .recent-active class.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant T as Table Component
    participant S as Styling Engine

    U->>T: Click on a table row
    T->>T: Check activeRowHistory length
    alt activeRowHistory exceeds MAX
        T->>T: Remove oldest row entry
    end
    T->>T: Add clicked row to activeRowHistory
    T->>T: Call formatRow for rendering
    alt Row is second most recently activated
        T->>S: Apply .recent-active style
    end
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot 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 introduces recent active row markers to the table component by tracking recently activated rows.

  • Added an activeRowHistory array and a MAX_ACTIVE_ROW_HISTORY constant to limit its size
  • Updated row activation logic to store active rows and conditionally add a visual "recent-active" marker
  • Minor formatting improvements for conciseness
Files not reviewed (1)
  • src/components/table/partial-styles/tabulator-custom-styles.scss: Language not supported

@@ -705,7 +708,17 @@ export class Table {
this.activeRow = row.getData();
}

if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {
Copy link
Preview

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

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

The clicked row is only being added to the history when the length is already greater than MAX_ACTIVE_ROW_HISTORY, which may prevent initial active rows from getting recorded. Consider always pushing the clicked row to activeRowHistory and then trimming the array if its length exceeds MAX_ACTIVE_ROW_HISTORY.

Suggested change
if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {

Copilot uses AI. Check for mistakes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d7e67b and b961432.

📒 Files selected for processing (2)
  • src/components/table/partial-styles/tabulator-custom-styles.scss (1 hunks)
  • src/components/table/table.tsx (7 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.tsx`: Our `.tsx` files are typically using StencilJS, not React.

**/*.tsx: Our .tsx files are typically using StencilJS, not React.

  • src/components/table/table.tsx
`**/*.{ts,tsx}`: Imports from other files in the same module (lime-elements) must use relative paths. Using absolute paths for imports will cause the production build to fail.

**/*.{ts,tsx}: Imports from other files in the same module (lime-elements) must use relative paths. Using absolute paths for imports will cause the production build to fail.

  • src/components/table/table.tsx
🪛 GitHub Actions: Pull Request Checks
src/components/table/table.tsx

[error] 724-724: TypeScript: Declaration or statement expected.

🔇 Additional comments (5)
src/components/table/partial-styles/tabulator-custom-styles.scss (1)

90-105: Good implementation of visual indicator for recently active rows.

The new .recent-active class with its :before pseudo-element successfully creates a visual indicator for recently active rows. The styling is consistent with the existing .active class pattern but uses a lighter color (rgb(211, 211, 211)) to differentiate it from the currently active row.

src/components/table/table.tsx (4)

103-111: Good addition of active row history tracking.

The new private properties for tracking active row history are well-named and documented. The use of a static constant for the maximum history size makes the code more maintainable.


762-771: Good implementation of recent active row highlighting.

The code correctly identifies the previous active row from the history and applies the recent-active class to it. The implementation is clean and follows the existing pattern for the active class.


647-647: Approved code style improvement.

Condensing the load object into a single line improves code readability.


815-815: Approved code style improvement.

Condensing the column options object into a single line is a good refactoring for consistency.

Comment on lines +711 to +721
if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {
const clickedRow = this.tabulator.getRow(row.getData().id);
this.activeRowHistory.push(clickedRow);

// Keep the history array limited to the last two rows
if (this.activeRowHistory.length > 2) {
this.activeRowHistory.shift();
}

this.activate.emit(this.activeRow);
this.formatRows();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the syntax error in the active row history logic.

There's a syntax error in the conditional logic for managing the activeRowHistory. The condition on line 711 is checking if the length exceeds MAX_ACTIVE_ROW_HISTORY, but there's no corresponding closing brace for this condition before continuing execution.

Apply this diff to fix the issue:

-        if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {
        const clickedRow = this.tabulator.getRow(row.getData().id);
        this.activeRowHistory.push(clickedRow);

        // Keep the history array limited to the last two rows
        if (this.activeRowHistory.length > 2) {
            this.activeRowHistory.shift();
        }

Either remove the first condition or properly structure the conditional blocks:

        const clickedRow = this.tabulator.getRow(row.getData().id);
        this.activeRowHistory.push(clickedRow);

        // Keep the history array limited to the last two rows
        if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {
            this.activeRowHistory.shift();
        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {
const clickedRow = this.tabulator.getRow(row.getData().id);
this.activeRowHistory.push(clickedRow);
// Keep the history array limited to the last two rows
if (this.activeRowHistory.length > 2) {
this.activeRowHistory.shift();
}
this.activate.emit(this.activeRow);
this.formatRows();
const clickedRow = this.tabulator.getRow(row.getData().id);
this.activeRowHistory.push(clickedRow);
// Keep the history array limited to the maximum number of active rows
if (this.activeRowHistory.length > Table.MAX_ACTIVE_ROW_HISTORY) {
this.activeRowHistory.shift();
}
this.activate.emit(this.activeRow);
this.formatRows();

'has-low-density': this.layout === 'lowDensity',
}}
>
<Host class={{ 'has-low-density': this.layout === 'lowDensity' }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@paulinewahle paulinewahle Apr 3, 2025

Choose a reason for hiding this comment

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

What do you mean @Kiarokh?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meat to link it to the previous comment about auto linting :)

Comment on lines +90 to +105
.recent-active {
&:before {
$width-of-selected-row-indicator: 0.2rem;
content: '';
display: inline-block;
box-sizing: border-box;
position: sticky;
z-index: $table--has-interactive-rows--selectable-row--hover +
1;
inset: 0 0 auto 0;
border: $width-of-selected-row-indicator solid
rgb(211, 211, 211);
border-radius: 1rem;
margin-right: -$width-of-selected-row-indicator * 2;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is mostly repetition of lines 48 to 60.
it's better to either make a mixin for these lines; or have a common CSS rule for both. The only difference is the colors of the dots, which can the be written in a separate CSS rule for each

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants