Skip to content

#39149 Drag to create can start above an existing item#101

Open
daniela-mateescu wants to merge 4 commits intomaster-flower-platformfrom
dana-RM39149-unable-to-drag-to-create-on-an-existing-item
Open

#39149 Drag to create can start above an existing item#101
daniela-mateescu wants to merge 4 commits intomaster-flower-platformfrom
dana-RM39149-unable-to-drag-to-create-on-an-existing-item

Conversation

@daniela-mateescu
Copy link
Collaborator

Proposed Change:

What is your change

Change type

Put an x in the boxes that apply

  • Bugfix
  • New feature

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@gemini-code-assist
Copy link

Summary of Changes

Hello @daniela-mateescu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the timeline component where the "drag to create" feature was not functional if the initial drag gesture began over an existing item. The changes modify the drag interaction configuration to allow this behavior and enhance the item selection logic to ensure that existing items are not inadvertently selected when a drag-to-create action is initiated on them.

Highlights

  • Drag-to-Create Interaction: Enabled the "drag to create" functionality to initiate even when the mouse down event occurs over an existing draggable item in the timeline.
  • Item Selection Logic: Adjusted the item selection mechanism to prevent an item from being immediately selected on "mousedown" if a drag-to-create operation is active and starts on that item. Selection is now deferred to "click" or "contextmenu" events in such cases.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements the ability to start a 'drag to create' action on top of an existing item without immediately selecting it. The changes achieve this by adjusting the draggable area and deferring item selection in drag-to-create mode. My feedback includes a suggestion to refactor a conditional statement for improved readability and maintainability.

Comment on lines 1741 to 1746
if (
(!this.getDragToCreateMode() && e.type == 'mousedown') ||
(this.getDragToCreateMode() && e.type == 'click') ||
(this.getDragToCreateMode() && e.type == 'contextmenu') ||
(this.isTouchDevice() && e.type == 'tap')
) {

Choose a reason for hiding this comment

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

medium

The logic in this if condition is correct, but it can be made more readable and slightly more efficient by factoring out the repeated call to this.getDragToCreateMode() into a constant. This will make the condition easier to understand at a glance. Using strict equality (===) is also a good practice.

Suggested change
if (
(!this.getDragToCreateMode() && e.type == 'mousedown') ||
(this.getDragToCreateMode() && e.type == 'click') ||
(this.getDragToCreateMode() && e.type == 'contextmenu') ||
(this.isTouchDevice() && e.type == 'tap')
) {
const isDragToCreate = this.getDragToCreateMode();
if (
(!isDragToCreate && e.type === 'mousedown') ||
(isDragToCreate && (e.type === 'click' || e.type === 'contextmenu')) ||
(this.isTouchDevice() && e.type === 'tap')
) {

Choose a reason for hiding this comment

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

Thanks for incorporating the suggestion! The change looks good and improves the readability and efficiency of the condition. The use of a constant isDragToCreate and strict equality (===) aligns with best practices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@daniela-mateescu
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enables the 'drag to create' functionality to be initiated even when the cursor is over an existing item. The changes in src/timeline.js correctly implement this by adjusting the ignoreFrom option for dragging and by modifying the item selection logic to defer selection until a click event occurs when in 'drag to create' mode. The code changes are solid. My only feedback is a minor correction needed in the CHANGELOG.md file.

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

Comments