Skip to content
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

feat(react-components): add hotkeys P to toggle the Poi tool and Esc to remove the Poi creation - including the floating panel #4909

Merged
merged 6 commits into from
Nov 28, 2024

Conversation

danpriori
Copy link
Contributor

Type of change

Feat

Jira ticket 📘

https://cognitedata.atlassian.net/browse/

Add hotkeys for Point of Interests.
P to toggle the tool and Esc to close/exit the creation

Test instructions ℹ️

  1. In Search UI, with a Scene loaded, press P to toggle the Poi tool from the left toolbar.
  2. Observe the tool is in enabling/disabling state.
  3. Click on a 3d geometry to start the Point of Interest creation.
  4. Focus the floating panel that has the Poi's description by typing in the description field or clicking the panel itself.
  5. Press Escape button from the keyboard.
  6. Observe the creation, including the floating panel, is removed from the view and the tool is disabled.

Checklist ☑️

  • I am proud of this feature.
  • I have performed a self-review of my own code.
  • I have added PR type (Feat, Bug, Chore, Test, Docs, Style, Refactor) to the PR title.
  • I have manually tested this for different scenarios (different models, formats, devices, browsers).
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the public documentation.
  • I have added unit and visuals tests to prove that my feature works to the best of my ability.
  • I have refactored the code for readability to the best of my ability.
  • I have checked that my changes do not introduce regressions in the public documentation.
  • I have outlined any known defects / lacking capabilities in the contents of this PR.
  • I have listed any remaining work that should follow this PR in the description or jira/miro/etc.
  • I have added TSDoc to any public facing changes.
  • I have added "developer documentation" in any package README.md that is related / applicable to this PR.
  • I have noted down and am currently tracking any technical debt introduced in this PR.
  • I have thoroughly thought about the architecture of this implementation.
  • I have asked peers to test this feature.

Copy link
Contributor

@haakonflatval-cognite haakonflatval-cognite left a comment

Choose a reason for hiding this comment

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

LGTM, just a few nitpicks

@@ -281,8 +281,12 @@ export abstract class BaseTool extends RenderTargetCommand {
/**
* AnchorDialog
*/

type CustomListener = { eventName: string; callback: (event: Event) => void };
Copy link
Contributor

Choose a reason for hiding this comment

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

Strictly speaking, this should be exported, since it's part of the other exported type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 25 to 27
dialogContent.customListeners.forEach((listener) => {
window.addEventListener(listener.eventName, listener.callback, true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nitpicky, but this could be a little shorter with dialogContent.customListeners?.forEach(... and removing the if-check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ops.. ofc

07d2588

Comment on lines 36 to 46
if (dialogContent === undefined || isSomeEnabled !== true) {
return undefined;
}

if (renderTarget === undefined) {
return <></>;
}

if (activeTool === undefined) {
return <></>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just combine all of these to one if-check? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep
07d2588

@danpriori danpriori enabled auto-merge (squash) November 28, 2024 17:04
@danpriori danpriori merged commit 6281903 into master Nov 28, 2024
14 checks passed
@danpriori danpriori deleted the danpriori/hotkeys-for-pois branch November 28, 2024 17:06
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