Skip to content

fix(AlertReportModal): Text Area Change#17176

Merged
eschutho merged 5 commits intoapache:masterfrom
preset-io:ch26993_alertReportsEdit
Oct 29, 2021
Merged

fix(AlertReportModal): Text Area Change#17176
eschutho merged 5 commits intoapache:masterfrom
preset-io:ch26993_alertReportsEdit

Conversation

@AAfghahi
Copy link
Member

@AAfghahi AAfghahi commented Oct 20, 2021

SUMMARY

There was an error report where users were reporting that sql values that they were inputting into the TextAreaControl section would linger even when they closed out and went to a new report, or even created a new report. This was because we were storing the sql in state, but not clearing state when a modal was closed.

This state was created to stop cursor errors here: #15820. I believe that @geido made this change.

The cursor errors were occurring because we added a debouncer to the ace-editor here: #10837

In investigating this, I was wondering why we had a debouncer for the ace editor to begin with? The input is not using an API, and looking through the different places where TextAreaControl is used, none of them make an API call. So this PR deletes the debouncer, which fixes both the cursor back issue and also gets rid of the state.value //prop.value difference.

However, I wanted to make sure that getting rid of this debouncer is fine @ktmud and @geido ? Where are the places that we should check to make sure?

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

CleanShot.2021-10-06.at.11.24.23.mp4

After:
https://user-images.githubusercontent.com/48933336/138182251-f5d5dfc0-c7dc-4066-a39a-b1b2b1b0cffd.mov

TESTING INSTRUCTIONS

Create an alert, exit out. Create another alert, there should not be any sql in the sql input form.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@pull-request-size pull-request-size bot added size/S and removed size/M labels Oct 21, 2021
@geido
Copy link
Member

geido commented Oct 21, 2021

@AAfghahi I would like to get the test env up. Please let me know when the CI passes. Thank you

@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch 2 times, most recently from 0e00ba3 to a35059e Compare October 21, 2021 15:02
@AAfghahi
Copy link
Member Author

@geido
I just fixed this test, so it should be passing. But I will ping you when the tests are fully passing (hoping that they are passing by the time you see this message ;) )

@codecov
Copy link

codecov bot commented Oct 21, 2021

Codecov Report

Merging #17176 (8846c7f) into master (dd71035) will increase coverage by 0.07%.
The diff coverage is 94.59%.

❗ Current head 8846c7f differs from pull request most recent head 5bab212. Consider uploading reports for the commit 5bab212 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17176      +/-   ##
==========================================
+ Coverage   76.95%   77.03%   +0.07%     
==========================================
  Files        1038     1037       -1     
  Lines       55612    55621       +9     
  Branches     7590     7594       +4     
==========================================
+ Hits        42798    42845      +47     
+ Misses      12564    12526      -38     
  Partials      250      250              
Flag Coverage Δ
javascript 71.15% <96.82%> (+0.13%) ⬆️

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

Impacted Files Coverage Δ
...t-frontend/src/components/AsyncAceEditor/index.tsx 88.00% <ø> (-0.47%) ⬇️
...nd/src/dashboard/components/nativeFilters/types.ts 100.00% <ø> (ø)
...perset-frontend/src/explore/components/Control.tsx 76.47% <ø> (ø)
...nts/controls/ConditionalFormattingControl/types.ts 100.00% <ø> (ø)
...rc/explore/components/controls/TextAreaControl.jsx 91.66% <ø> (+9.31%) ⬆️
superset/annotation_layers/schemas.py 100.00% <ø> (ø)
superset/connectors/sqla/models.py 87.39% <75.00%> (-0.09%) ⬇️
...Filters/FilterBar/FilterControls/FilterControl.tsx 94.87% <88.88%> (-5.13%) ⬇️
...end/src/components/Datasource/DatasourceEditor.jsx 76.09% <100.00%> (+3.98%) ⬆️
...onfigModal/FiltersConfigForm/FiltersConfigForm.tsx 69.32% <100.00%> (+0.07%) ⬆️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd71035...5bab212. Read the comment docs.

@eschutho
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@eschutho Ephemeral environment spinning up at http://52.41.148.26:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@ktmud
Copy link
Member

ktmud commented Oct 21, 2021

In general it's preferable to always add debounce to text inputs because even if they don't trigger remote API calls, they could still trigger expensive re-rendering. Not sure if this will work, but an alternative solution here could be to re-render the modal completely when users go to a new report, which can probably be achieved by setting a uniq key to the TextAreaControl component.

@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch from a35059e to 1c84645 Compare October 22, 2021 21:04
@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 22, 2021
@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch 4 times, most recently from 3fd8b61 to 0b4a49f Compare October 26, 2021 15:31
@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch from 0b4a49f to 973cfda Compare October 26, 2021 15:33
@AAfghahi
Copy link
Member Author

AAfghahi commented Oct 26, 2021

@ktmud Hey! So I followed your advice and added a key to the AlertReportModal which really helped thank you for that! I ended up not doing the key to the TextAreaControl and instead put it on the entire modal.

Regarding your point on the debouncer, doing some research I found that the react-ace editor has its own internal state for value and also has a built in debouncer, so I made the component into an uncontrolled component (though it still spreads props so the other places that use it will still be able to pass in value).

This did require us to bump up react-ace because our current version had a known bug that finished. One thing to note is that this does drop bracejs as a dependency, but we have bracejs in our package.json so I don't think it will affect us in that way.

@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch from e3f7e07 to 294ce97 Compare October 26, 2021 22:23
Copy link
Member

Choose a reason for hiding this comment

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

this looks like it will never change value if you type in it?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mentioned this in our pair programming as a potential issue so I tested it. I removed language from where we are invoking it in the AlertReportModal and got this
Screen Shot 2021-10-27 at 11 11 15 AM

Copy link
Member

Choose a reason for hiding this comment

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

does this generate a new key each time it rerenders?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, and I actually moved it over to the AlertReportModal because of this. Earlier I had done this and the state issue had still persisted, but when I test it now it is working fine. So I must have originally tested it during a bad iteration.

@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch 2 times, most recently from 2be1623 to 25da0b1 Compare October 28, 2021 21:44
Copy link
Member

Choose a reason for hiding this comment

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

There was a bug that I fixed on sql lab where if you passed in value as null (not undefined), sql lab would crash. Can you test to see if this was fixed with the new version of aceeditor?

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

This look really good. Just a few small questions since this component is used throughout the app.

@eschutho
Copy link
Member

/testenv up FEATURE_ALERT_REPORTS=true

@github-actions
Copy link
Contributor

@eschutho Ephemeral environment spinning up at http://54.218.96.39:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@rosemarie-chiu
Copy link
Contributor

@AAfghahi @eschutho I'm not sure if this is related to this fix, I found that I no longer able to see the query on the virtual dataset after this code change.

Steps:

  1. In Sql editor, run a query and explore save as new dataset
  2. Check the sql on the dataset and not able to see anything
  3. Only able to see the query on that virutal dataset when clicking on view in sql lab
sql.editor.of.dataset.mov

I tested on other Ephemeral env and do not reproduce this, so I suspect it is caused by this PR.

✅ regression test creating new alert, edit alert sql editor field not overwrites
✅ regression test sql editor save query, update saved query, multiple query tab

@eschutho
Copy link
Member

/testenv up ENABLE_TEMPLATE_PROCESSING=True FEATURE_ALERT_REPORTS=true

@eschutho
Copy link
Member

@AAfghahi @eschutho I'm not sure if this is related to this fix, I found that I no longer able to see the query on the virtual dataset after this code change.

Thanks @rosemarie-chiu! Nice catch... We'll take a look.

@github-actions
Copy link
Contributor

@eschutho Ephemeral environment spinning up at http://54.218.248.191:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@AAfghahi AAfghahi force-pushed the ch26993_alertReportsEdit branch from 25da0b1 to 5bab212 Compare October 29, 2021 19:40
@AAfghahi
Copy link
Member Author

@rosemarie-chiu you're amazing thank you! I made a change that catches that instance.

@eschutho
Copy link
Member

/testenv up ENABLE_TEMPLATE_PROCESSING=True FEATURE_ALERT_REPORTS=true

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

looks great!

@github-actions
Copy link
Contributor

@eschutho Ephemeral environment spinning up at http://54.213.225.219:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Contributor

@rosemarie-chiu rosemarie-chiu left a comment

Choose a reason for hiding this comment

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

LGTM! QA sign-off tested:
✅ SQL editor in sql lab
✅ SQL editor in alert
✅ SQL editor in dataset edit modal

@eschutho eschutho merged commit 5948a9f into apache:master Oct 29, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@eschutho eschutho added the v1.4 label Nov 18, 2021
eschutho pushed a commit that referenced this pull request Nov 22, 2021
* Text Area Change

* added unique key to component

* tests passing

* changed css

* data flow and naming convention

(cherry picked from commit 5948a9f)
AAfghahi added a commit that referenced this pull request Jan 10, 2022
* Text Area Change

* added unique key to component

* tests passing

* changed css

* data flow and naming convention
@Renderz
Copy link
Contributor

Renderz commented Jun 1, 2022

I wonder why to remove 'props.value' from TextArea, which should always render the value be given.
Suppose I want to manually change the datasource instead of typing in TextArea itself, value should be injected from props, and should also be rendered correctly.

@mistercrunch mistercrunch added 🍒 1.4.0 Cherry-picked to 1.4.0 🍒 1.4.1 Cherry-picked to 1.4.1 🍒 1.4.2 Cherry-picked to 1.4.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 First shipped in 1.5.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels hold:testing! On hold for testing size/M v1.4 🍒 1.4.0 Cherry-picked to 1.4.0 🍒 1.4.1 Cherry-picked to 1.4.1 🍒 1.4.2 Cherry-picked to 1.4.2 🚢 1.5.0 First shipped in 1.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

Comments