Skip to content

popup separated #736

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

popup separated #736

wants to merge 1 commit into from

Conversation

revolist
Copy link
Owner

@revolist revolist commented Apr 16, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a filter popup component for enhanced filtering UI, allowing the filter panel to appear within a dedicated popup.
    • Added support for closing the filter popup by clicking outside, improving user experience.
  • Refactor

    • Separated filter panel and popup logic for clearer UI structure and better maintainability.
    • Updated styling to distinguish between the popup container and the filter panel.
  • Documentation

    • Updated documentation references for the latest changes.
  • Bug Fixes

    • Improved popup positioning to prevent overflow beyond grid boundaries.

@revolist
Copy link
Owner Author

@CodeRabbit summary

Copy link

coderabbitai bot commented Apr 16, 2025

✅ Actions performed

Summary regeneration triggered.

Copy link

coderabbitai bot commented Apr 16, 2025

Walkthrough

This change refactors the filter UI system by introducing a new revogr-filter-popup component that encapsulates popup behavior, including positioning and closing on outside clicks. The previous closeOnOutsideClick logic is removed from the filter panel and transferred to the new popup component. The filter plugin is updated to manage both the popup and panel, coordinating their visibility and interactions. Type declarations, event types, and CSS selectors are updated to reflect the separation between popup and panel. The new structure improves modularity and control over filter popup behavior.

Changes

File(s) Change Summary
src/components.d.ts Removed closeOnOutsideClick from RevogrFilterPanel; changed show return type; added new RevogrFilterPopup interface and related event, element, and JSX typings for the popup component.
src/plugins/filter/filter.panel.tsx Removed outside click event handler and closeOnOutsideClick prop; deleted autoCorrect method; refactored rendering logic by splitting into renderContent and a simplified render; updated show to return rendered content.
src/plugins/filter/filter.plugin.tsx Added FILTER_POPUP constant; refactored to manage both popup and panel references; nested panel inside new popup component; moved outside click logic to popup; updated show/hide logic for both components; adjusted event handlers and props accordingly.
src/plugins/filter/filter.popup.tsx New file: Implements revogr-filter-popup component with show/hide methods, outside click detection, position adjustment, and close event emission; manages visibility and coordinates; renders slot content when visible.
src/plugins/filter/filter.style.scss Renamed and split CSS selectors: moved most container styles from revogr-filter-panel to revogr-filter-popup, leaving minimal styles for the panel; reorganized for new component structure.
src/types/events.ts Added 'close' event to RevogridEvents type union and REVOGRID_EVENTS map.
docs (subproject reference update) Updated subproject commit reference for docs directory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FilterButton
    participant FilterPopup
    participant FilterPanel
    participant Grid

    User->>FilterButton: Clicks filter button
    FilterButton->>FilterPopup: show(x, y)
    FilterPopup->>FilterPanel: show()
    Note right of FilterPanel: User interacts with filter UI
    User->>FilterPopup: Clicks outside (if enabled)
    FilterPopup->>FilterPopup: Detects outside click
    FilterPopup->>FilterPopup: hide()
    FilterPopup->>FilterPanel: hide()
    FilterPopup-->>Grid: Emits "close" event
Loading

Possibly related PRs

  • revolist/revogrid#721: Adds closeOnOutsideClick property to the filter panel interface, which is further refactored and extended in this PR with the introduction of the popup component.

Suggested labels

feature, breaking-change

Poem

A popup appears with a hop and a wink,
No more panels closing before you can blink!
Now outside clicks are caught with care,
The filter floats gently, right where you stare.
With modular code, the grid feels brand new—
Hooray for the popup, and cheers to the crew!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ 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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

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

🔭 Outside diff range comments (1)
src/plugins/filter/filter.panel.tsx (1)

417-488: 🛠️ Refactor suggestion

Add key properties to elements in iterables

The renderContent method returns an array of JSX elements without key properties, which may cause rendering optimization issues.

- return [
-   <slot slot="header" />,
-   this.changes.extraContent?.(this.changes) || '',
+  return [
+   <slot key="header-slot" slot="header" />,
+   <div key="extra-content">{this.changes.extraContent?.(this.changes) || ''}</div>,

    this.changes?.hideDefaultFilters !== true ? (
      [
-       <label>{capts.title}</label>,
-       <div class="filter-holder">{this.getFilterItemsList()}</div>,
-       <div class="add-filter">
+       <label key="filter-label">{capts.title}</label>,
+       <div key="filter-holder" class="filter-holder">{this.getFilterItemsList()}</div>,
+       <div key="add-filter" class="add-filter">
          <select
            id={FILTER_ID}
            class="select-css"
            onChange={e => this.onAddNewFilter(e)}
          >
            {this.renderSelectOptions(this.currentFilterType)}
          </select>
        </div>
      ]
    ) : '',

-   <slot />,
+   <slot key="default-slot" />,
    <div class="filter-actions">
      {this.disableDynamicFiltering && [
        <button
+         key="save-button"
          id="revo-button-save"
          aria-label="save"
          class="revo-button green"
          onClick={() => this.onSave()}
        >
          {capts.save}
        </button>,
        <button
+         key="cancel-button-1"
          id="revo-button-ok"
          aria-label="ok"
          class="revo-button green"
          onClick={() => this.onCancel()}
        >
          {capts.cancel}
        </button>,
      ]}
      {!this.disableDynamicFiltering && [
        <button
+         key="ok-button"
          id="revo-button-ok"
          aria-label="ok"
          class="revo-button green"
          onClick={() => this.onCancel()}
        >
          {capts.ok}
        </button>,

        <button
+         key="reset-button"
          id="revo-button-reset"
          aria-label="reset"
          class="revo-button outline"
          onClick={() => this.onReset()}
        >
          {capts.reset}
        </button>,
      ]}
    </div>,
-   <slot slot="footer" />];
+   <slot key="footer-slot" slot="footer" />];
🧰 Tools
🪛 Biome (1.9.4)

[error] 428-428: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 447-447: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 448-448: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 487-487: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 433-433: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 434-434: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 435-435: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 450-455: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 458-463: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 468-473: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 477-482: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🧹 Nitpick comments (2)
src/plugins/filter/filter.plugin.tsx (2)

63-64: References added for popup and panel.
The popupRef and panelRef fields allow you to manipulate the popup and panel elements directly. Ensure they are properly cleaned up or nulled out if there’s any teardown logic required in the future.


158-163: Suggestion to add dedicated "hide" method on panel.
Currently, the panel is closed by calling show(undefined). While valid, a dedicated hide() method on the panel might clarify the intended action.

- if (this.panelRef) {
-   this.panelRef.show(undefined);
- }
+ if (this.panelRef?.hide) {
+   this.panelRef.hide();
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1645225 and 3e99740.

📒 Files selected for processing (7)
  • docs (1 hunks)
  • src/components.d.ts (7 hunks)
  • src/plugins/filter/filter.panel.tsx (5 hunks)
  • src/plugins/filter/filter.plugin.tsx (5 hunks)
  • src/plugins/filter/filter.popup.tsx (1 hunks)
  • src/plugins/filter/filter.style.scss (1 hunks)
  • src/types/events.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components.d.ts (1)
src/plugins/filter/filter.types.ts (1)
  • ShowData (160-173)
🪛 Biome (1.9.4)
src/plugins/filter/filter.plugin.tsx

[error] 92-96: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

src/plugins/filter/filter.panel.tsx

[error] 428-428: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 447-447: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 487-487: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

src/components.d.ts

[error] 1049-1049: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

🔇 Additional comments (24)
docs (1)

1-1:

❓ Verification inconclusive

Documentation subproject reference updated.

The documentation subproject reference has been updated to commit 4ffe7c9ac2a849d04231551308fd462b366b3c19. This update is necessary to align the documentation with the code changes, particularly the introduction of the new revogr-filter-popup component and related filter UI refactoring.

Please ensure that the documentation properly reflects the new component structure and API changes made in this PR. Specifically, check that:

  1. The new revogr-filter-popup component is documented
  2. The updated filter plugin API is correctly described
  3. Any changes to event types and interactions are properly documented

🏁 Script executed:

#!/bin/bash
# Check if the documentation has been updated to include references to the new filter popup component
echo "Checking docs for references to the new filter popup component..."
cd docs
git show -p | grep -i "filter-popup"
echo "Done checking docs."

Length of output: 631


The documentation shows clear evidence that the new revogr-filter-popup component is referenced in multiple locations, including the component’s type definitions and HTML usage. However, please take an additional manual look to confirm that the updated filter plugin API description and any new event type or interaction changes have been comprehensively covered in the docs.

Next Steps for Verification:

  • Confirm that the documentation clearly explains the new filter plugin API changes.
  • Verify that any changes to event types and interactions are also described.
src/types/events.ts (2)

60-60: LGTM: Event type addition for popup closing

Adding the 'close' event supports the new popup component's ability to notify when it's closed due to outside clicks.


170-170: LGTM: Event mapping added to constants

Consistent update to the REVOGRID_EVENTS map to include the new 'close' event type.

src/plugins/filter/filter.style.scss (2)

1-18: LGTM: CSS reorganization for popup component

The styles have been appropriately moved from panel to popup, maintaining the same visual styling while supporting the component separation. This CSS restructuring properly encapsulates the positioning, visibility, and container styles in the new popup component.


20-23: LGTM: Simplified panel styling

The panel component now has simplified styles focused on display and width, which aligns with its reduced responsibilities after the refactoring.

src/plugins/filter/filter.popup.tsx (6)

1-12: LGTM: Well-structured imports

Good organization of imports for Stencil.js decorators and lifecycle hooks.


14-27: LGTM: Component setup and property definitions

The component is properly set up with state variables for visibility and position, and exposes the necessary events and properties.


29-39: LGTM: Show/hide methods implementation

The show and hide methods provide a clean API for controlling the popup's visibility and position.


41-58: LGTM: Outside click detection logic

The global mousedown listener correctly implements outside click detection and emits the close event when appropriate.


60-77: LGTM: Position auto-correction implementation

The auto-correction logic ensures the popup stays within the grid boundaries, improving usability.


79-95: LGTM: Conditional rendering based on visibility

The render method appropriately handles visibility state and applies inline positioning styles when visible.

src/plugins/filter/filter.panel.tsx (3)

17-17: LGTM: Updated imports

Import statement now correctly imports only the button components needed without including the isFilterBtn helper which is now used in the popup component.


75-84: LGTM: Simplified show method

The show method has been refactored to focus on setting state and returning rendered content, delegating positioning logic to the parent popup component.


490-496: LGTM: Simplified render method

The render method has been simplified to use the new renderContent method, which improves code organization.

src/plugins/filter/filter.plugin.tsx (7)

36-37: Constants look good.
These new constants FILTER_PANEL and FILTER_POPUP are simple and descriptive, and they align with the refactored components.


88-88: Filter logic is clear.
Filtering out any previous panel or popup references from registerVNode before adding new ones looks fine.


92-96: Potential false-positive lint warning about missing key property.
A static analysis hint flags missing keys in an iterable, but this appears to be Stencil code rather than React. If this is not a React environment or you don't render multiple instances of this element in a loop, that warning can be safely ignored. Otherwise, consider adding a unique key prop if these nodes are indeed iterated.

🧰 Tools
🪛 Biome (1.9.4)

[error] 92-96: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


102-102: Configuration binding is consistent.
Passing disableDynamicFiltering directly from config is straightforward, ensuring your panel is aware of dynamic filtering behavior.


165-171: Good approach to toggle panel & popup visibility.
The beforeshow method logically opens or closes both the popup and panel based on the presence of data. This centralizes control nicely.


175-175: Returning extra content is fine.
extraHyperContent is optional, so these lines make sense. Just ensure null or undefined is handled gracefully within the content consumer.


256-256: Null/undefined check is straightforward.
The guard clause cleanly exits if relevant references are missing. This is a simple and safe approach.

src/components.d.ts (3)

452-453: Clearer return type for “show” method.
The show method returning Promise<any[] | null> is acceptable, but documenting its return usage might help future maintainers.


454-457: New popup interface.
Defining RevogrFilterPopup is a good abstraction for popup management. The doc comment helps keep code self-documenting.


768-771: Custom event interface matches existing pattern.
RevogrFilterPopupCustomEvent<T> follows the same structure as other custom event interfaces, ensuring consistency for typed events.

Comment on lines +1049 to +1050
"close": void;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace “void” with “undefined” to satisfy lint.
Static analysis warns that void can be confusing here. Updating "close": undefined; aligns better with typical TypeScript usage:

- "close": void;
+ "close": undefined;
📝 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
"close": void;
}
"close": undefined;
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 1049-1049: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

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