Skip to content

773 chipblock linkbug #1195

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

Merged
merged 7 commits into from
May 27, 2025
Merged

773 chipblock linkbug #1195

merged 7 commits into from
May 27, 2025

Conversation

SindhuHarika
Copy link
Contributor

Description

Implemented the navigation for link option of chip block

Changes Made

Implemented the navigation for link option of chip block

@SindhuHarika SindhuHarika requested a review from a team as a code owner May 21, 2025 10:51
Copy link

@CodiumAI-Agent /describe

@CodiumAI-Agent
Copy link

Title

773 chipblock linkbug


User description

Description

Implemented the navigation for link option of chip block

Changes Made

Implemented the navigation for link option of chip block


PR Type

Bug fix


Description

  • Enable chip link to open in new tab

  • Prevent default navigation before opening

  • Use noopener,noreferrer for security


Changes walkthrough 📝

Relevant files
Enhancement
ChipBlock.tsx
Enhance chip link click behavior                                                 

libs/renderer/src/components/block-defaults/chip-block/ChipBlock.tsx

  • Replaced simple e.preventDefault() handler
  • Added window.open(link, '_blank', 'noopener,noreferrer')
  • Ensured link opens in new tab securely
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @SindhuHarika SindhuHarika linked an issue May 21, 2025 that may be closed by this pull request
    Copy link

    @CodiumAI-Agent /review

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    CodiumAI-Agent commented May 21, 2025

    PR Code Suggestions ✨

    Latest suggestions up to 383d8b7

    CategorySuggestion                                                                                                                                    Impact
    Security
    Add noopener noreferrer rel

    Add a rel="noopener noreferrer" attribute to any anchor using target="_blank" to
    prevent reverse tabnabbing attacks. This ensures the new page cannot access your
    window object.

    libs/renderer/src/components/block-defaults/chip-block/ChipBlock.tsx [141]

    -<a href={link} target="_blank">
    +<a href={link} target="_blank" rel="noopener noreferrer">
    Suggestion importance[1-10]: 8

    __

    Why: Adding rel="noopener noreferrer" prevents reverse tabnabbing and is a best practice when using target="_blank" for security.

    Medium

    Previous suggestions

    Suggestions up to commit 8d53e62
    CategorySuggestion                                                                                                                                    Impact
    Security
    Use anchor target and rel

    Replace the manual window.open call and preventDefault handler with native anchor
    attributes for opening a new tab securely and remove the inline click handler. This
    improves accessibility and simplifies the code.

    libs/renderer/src/components/block-defaults/chip-block/ChipBlock.tsx [141-146]

    -<a href={link}>
    -    <Chip
    -        {...chipProps}
    -        onClick={(e) => {e.preventDefault();window.open(link, '_blank','noopener,noreferrer')}}
    -    />
    +<a href={link} target="_blank" rel="noopener noreferrer">
    +    <Chip {...chipProps} />
     </a>
    Suggestion importance[1-10]: 7

    __

    Why: Using native target="_blank" and rel="noopener noreferrer" simplifies the code, improves security and accessibility, and removes unnecessary inline JS.

    Medium
    Possible issue
    Guard against undefined link

    Add a guard to ensure link is defined before calling window.open to avoid runtime
    errors when link is undefined or empty.

    libs/renderer/src/components/block-defaults/chip-block/ChipBlock.tsx [144]

    -onClick={(e) => {e.preventDefault();window.open(link, '_blank','noopener,noreferrer')}}
    +onClick={(e) => {
    +    e.preventDefault();
    +    if (!link) return;
    +    window.open(link, '_blank', 'noopener,noreferrer');
    +}}
    Suggestion importance[1-10]: 5

    __

    Why: Adding a check for undefined link prevents runtime errors but has minor impact on functionality.

    Low

    @@ -141,7 +141,7 @@ export const ChipBlock: BlockComponent = observer(({ id }) => {
    <a href={link}>
    <Chip
    {...chipProps}
    onClick={(e) => e.preventDefault()}
    onClick={(e) => {e.preventDefault();window.open(link, '_blank','noopener,noreferrer')}}
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    why does the Chip need an onClick when there is an anchor tag wrapping it? can't we get rid of the onClick on the chip altogether and use the anchor tag?

    @johbaxter
    Copy link
    Contributor

    @Mezzet link on chip fix, take a look at code

    @johbaxter johbaxter merged commit 235ee7d into dev May 27, 2025
    3 checks passed
    @johbaxter johbaxter deleted the 773-chipblock-linkbug branch May 27, 2025 15:02
    Copy link

    @CodiumAI-Agent /update_changelog

    @CodiumAI-Agent
    Copy link

    Changelog updates: 🔄

    2025-05-27 #1195

    Added

    • navigation support for chip block link option, opening links in a new tab

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    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.

    Chip Block - Link settings bug
    4 participants