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

[Discover] Query Editor Shortcut Fires Incorrect Query #9248

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sejli
Copy link
Member

@sejli sejli commented Jan 22, 2025

Description

  • When using keyboard shortcuts to run a query in Discover 2.0, the date range gets reverted to Discover's last date range state. Since there is no date range passed into the onSubmit() function from the editor shortcut, the QueryEditorTopRow uses the props passed from the search bar as dates, which may be out of sync compared to the query service state. This PR passes in the correct date form the query service.
  • Additionally, in the multiline editor, the query object was being used to construct the new query. This PR updates it to match the single line editor, which uses the queryRef defined in the same file.

Issues Resolved

Screenshot

Testing the changes

Changelog

-fix: Fix Discover query editor enter shortcuts reverting date range

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Sean Li <[email protected]>
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 61.66%. Comparing base (b04af6b) to head (176eb68).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...ugins/data/public/ui/query_editor/query_editor.tsx 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9248      +/-   ##
==========================================
- Coverage   61.66%   61.66%   -0.01%     
==========================================
  Files        3817     3817              
  Lines       91711    91712       +1     
  Branches    14515    14515              
==========================================
- Hits        56558    56556       -2     
- Misses      31524    31526       +2     
- Partials     3629     3630       +1     
Flag Coverage Δ
Linux_1 29.04% <ø> (ø)
Linux_2 56.45% <ø> (ø)
Linux_3 39.08% <0.00%> (-0.01%) ⬇️
Linux_4 28.98% <ø> (ø)
Windows_1 29.05% <ø> (ø)
Windows_2 56.40% <ø> (ø)
Windows_3 39.09% <0.00%> (-0.01%) ⬇️
Windows_4 28.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kavilla kavilla added backport 2.x discover for discover reinvent labels Jan 23, 2025
@kavilla
Copy link
Member

kavilla commented Jan 23, 2025

did we want to get this into 2.19?

@@ -354,11 +355,11 @@ export const QueryEditorUI: React.FC<Props> = (props) => {

editor.addCommand(monaco.KeyCode.Enter, () => {
const newQuery = {
...query,
...queryRef.current,
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding this change, I see that earlier in the file, queryRef exists for monaco 'commands' to access the latest query state.
If query was a stale query state, why wasn't the single line editor failing a test that would update the query?
If there is a test for an updated query state, and query has the updated query state, do we need queryRef at all? It only seems to be used here.

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

Successfully merging this pull request may close these issues.

4 participants