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

fix: Fix auto-reversion of label/title in the Metrics popover #19889

Conversation

diegomedina248
Copy link
Contributor

SUMMARY

When editing a metric in the Explore, the title label that's automatically set when using the Custom SQL mode gets reset if you hover over it/change tabs/interact with the popover.

The reason is because the component is always being rerender, and in that case, the metric get's a new id and the label state is lost.

This PR caches the metric component so that it only rerenders when needed.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

old.mov

After:

new.mov

TESTING INSTRUCTIONS

  1. Select any chart to Explore
  2. Drag a new metric/edit an existing one
  3. Go to Custom SQL mode
  4. Enter any custom SQL

Ensure the title changes to match the sql entered.
Ensure hovering the title doesn't reset it.

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

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #19889 (2ec8bfd) into master (d5ea537) will increase coverage by 0.06%.
The diff coverage is 100.00%.

❗ Current head 2ec8bfd differs from pull request most recent head c3e4e5d. Consider uploading reports for the commit c3e4e5d to get more accurate results

@@            Coverage Diff             @@
##           master   #19889      +/-   ##
==========================================
+ Coverage   66.46%   66.53%   +0.06%     
==========================================
  Files        1714     1714              
  Lines       65031    65033       +2     
  Branches     6716     6717       +1     
==========================================
+ Hits        43224    43269      +45     
+ Misses      20100    20057      -43     
  Partials     1707     1707              
Flag Coverage Δ
javascript 51.27% <100.00%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
...hart-echarts/src/MixedTimeseries/transformProps.ts 0.00% <ø> (ø)
...gin-chart-echarts/src/Timeseries/transformProps.ts 57.89% <ø> (ø)
...lugin-chart-echarts/src/Timeseries/transformers.ts 51.63% <100.00%> (+0.39%) ⬆️
...controls/DndColumnSelectControl/DndSelectLabel.tsx 75.00% <100.00%> (+2.27%) ⬆️
...c/views/CRUD/data/database/DatabaseModal/index.tsx 32.51% <100.00%> (ø)
superset/models/core.py 89.33% <0.00%> (+0.23%) ⬆️
superset/connectors/sqla/models.py 90.04% <0.00%> (+1.01%) ⬆️
superset/db_engine_specs/presto.py 88.70% <0.00%> (+4.72%) ⬆️
...rols/MetricControl/AdhocMetricEditPopoverTitle.jsx 72.00% <0.00%> (+12.00%) ⬆️
...ntrols/MetricControl/AdhocMetricPopoverTrigger.tsx 83.78% <0.00%> (+13.51%) ⬆️

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 d5ea537...c3e4e5d. Read the comment docs.

@rusackas
Copy link
Member

rusackas commented May 4, 2022

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2022

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

Copy link
Member

@rusackas rusackas 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, and seems to work great!

One weird thing that might be worth a follow-up task... when you customize the metric title, it's super annoying that you can't hit enter to save it. You have to click outside the input somewhere to de-focus. That's annoying.

@rusackas rusackas merged commit 7b5ba39 into apache:master May 6, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

Ephemeral environment shutdown and build artifacts deleted.

hughhhh pushed a commit to hve-labs/superset that referenced this pull request May 11, 2022
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.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 Preset-Patch size/M 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants