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

Merged
merged 2 commits into from
Jan 28, 2025

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

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.68%. Comparing base (49f42c4) to head (b765af2).
Report is 9 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.69%   61.68%   -0.02%     
==========================================
  Files        3816     3816              
  Lines       91693    91694       +1     
  Branches    14516    14516              
==========================================
- Hits        56569    56559      -10     
- Misses      31498    31510      +12     
+ Partials     3626     3625       -1     
Flag Coverage Δ
Linux_1 29.04% <ø> (ø)
Linux_2 56.46% <ø> (ø)
Linux_3 39.09% <0.00%> (+<0.01%) ⬆️
Linux_4 28.97% <ø> (ø)
Windows_1 29.06% <ø> (-0.02%) ⬇️
Windows_2 56.41% <ø> (ø)
Windows_3 39.09% <0.00%> (-0.01%) ⬇️
Windows_4 28.97% <ø> (ø)

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.

@sejli sejli force-pushed the discover-enter-bug branch from 176eb68 to b765af2 Compare January 27, 2025 23:14
@sejli sejli merged commit 57c4424 into opensearch-project:main Jan 28, 2025
68 of 69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 28, 2025
* fix discover enter bug

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

* Changeset file for PR #9248 created/updated

---------

Signed-off-by: Sean Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 57c4424)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruchidh pushed a commit to ruchidh/OpenSearch-Dashboards that referenced this pull request Jan 30, 2025
…oject#9248)

* fix discover enter bug

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

* Changeset file for PR opensearch-project#9248 created/updated

---------

Signed-off-by: Sean Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Ubuntu <[email protected]>
sejli added a commit that referenced this pull request Jan 30, 2025
* fix discover enter bug



* Changeset file for PR #9248 created/updated

---------



(cherry picked from commit 57c4424)

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Sean Li <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 30, 2025
* fix discover enter bug

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

* Changeset file for PR #9248 created/updated

---------

Signed-off-by: Sean Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 57c4424)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
sejli pushed a commit that referenced this pull request Jan 31, 2025
* fix discover enter bug



* Changeset file for PR #9248 created/updated

---------



(cherry picked from commit 57c4424)

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
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