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: incorrect cursor position Firefox #12423

Merged
merged 4 commits into from Jan 15, 2021

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Jan 11, 2021

SUMMARY

When using SQL Lab in Firefox, the position of the cursor will drift to the left progressively along the row. As the cursor moves to the right, it's shifted more and more to the left, to a point where it shows up in the incorrect position.

This seems to be a known bug: https://stackoverflow.com/questions/20931029/ace-editor-monospace-fonts-issues-with-cursor-spacing

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Here's a query in Firefox, with the cursor moved to the end of the line:

Screenshot_2021-01-11 Superset(1)

Note how it looks like the cursor is to the left of the semi-colon — it's not, and if the user presses delete the semi-colon will be deleted instead!

Here's the same query with this fix:

Screenshot_2021-01-11 Superset

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@betodealmeida
Copy link
Member Author

cc: @eschutho

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

can you verify that this still works as expected in chrome and safari? We've fixed this same bug a number of times in various browsers.

@@ -208,6 +208,10 @@ div.Workspace {
.ace_content {
height: 100%;
}

.ace_editor * {
font: inherit!important;
Copy link
Member

Choose a reason for hiding this comment

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

ugh, !important 🤮 I guess if this is the only way to fix it then it's ok

Although, do we need to apply this to all elements that are descendants of .ace_editor or can we be more specific here? Also, could you add a space between inherit and !important?

Copy link
Member

Choose a reason for hiding this comment

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

It seems that the issue is around the bolded typeface in Fira Code, with the same issue with Inter and monospace. The only one I was able to get to work was "Courier New" so far. Targeting just the bold text seems to work (nested under .ace_editor.ace_editor) if you don't want to change everything:

.ace_keyword {
    font-family: 'Courier New';
  }

we could try out a few different common system fonts if you want to try to find a sans serif.

Copy link
Member

Choose a reason for hiding this comment

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

"Menlo" works and is sans serif, but for Mac only if you want to add that and fall back to Courier.

@codecov-io
Copy link

codecov-io commented Jan 12, 2021

Codecov Report

Merging #12423 (1bd9d37) into master (e9d66e9) will decrease coverage by 2.97%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12423      +/-   ##
==========================================
- Coverage   66.12%   63.15%   -2.98%     
==========================================
  Files        1015      486     -529     
  Lines       49554    29956   -19598     
  Branches     5079        0    -5079     
==========================================
- Hits        32767    18918   -13849     
+ Misses      16647    11038    -5609     
+ Partials      140        0     -140     
Flag Coverage Δ
cypress ?
javascript ?
python 63.15% <ø> (-0.94%) ⬇️

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

Impacted Files Coverage Δ
superset/db_engines/hive.py 0.00% <0.00%> (-85.72%) ⬇️
superset/examples/world_bank.py 30.98% <0.00%> (-69.02%) ⬇️
superset/sql_validators/postgres.py 50.00% <0.00%> (-50.00%) ⬇️
superset/db_engine_specs/hive.py 54.61% <0.00%> (-29.24%) ⬇️
superset/examples/helpers.py 85.36% <0.00%> (-12.20%) ⬇️
superset/db_engine_specs/sqlite.py 65.62% <0.00%> (-9.38%) ⬇️
superset/databases/commands/create.py 83.67% <0.00%> (-8.17%) ⬇️
superset/databases/commands/update.py 85.71% <0.00%> (-8.17%) ⬇️
superset/connectors/sqla/models.py 84.31% <0.00%> (-6.28%) ⬇️
superset/views/datasource.py 89.39% <0.00%> (-5.61%) ⬇️
... and 556 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 e9d66e9...1bd9d37. Read the comment docs.

@betodealmeida
Copy link
Member Author

I switched to @eschutho's approach, which seems more conservative.

@etr2460, It works fine in Firefox:

Screenshot_2021-01-12 Superset

And Chrome:

localhost_8088_superset_sqllab

But Safari is broken in master:

Screen Shot 2021-01-12 at 6 24 11 PM

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

stamping, could you also file an issue for the Safari UX bug?

Finally, does this need to be changed in other places where we use the code editor as well? Dataset edit modal, adhoc metric popover, etc.?

@@ -378,7 +378,9 @@ div.tablePopover {
//double class is better than !important
border: 1px solid @gray-light;
font-feature-settings: @font-feature-settings;
font-family: @font-family-monospace;
// Fire Code causes problem with Ace under Firefox
Copy link
Member

Choose a reason for hiding this comment

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

sp nit, i think it's Fira Code

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

font-family: @font-family-monospace;
// Fire Code causes problem with Ace under Firefox
font-family: 'Menlo', 'Courier New', 'Ubuntu Mono', 'Consolas',
'source-code-pro', monospace;
Copy link
Member

@eschutho eschutho Jan 13, 2021

Choose a reason for hiding this comment

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

Two small things..We could target just the bold typeface by using the selector .ace_editor.ace_editor .ace_keyword if we wanted to just change the bold typeface. Also talking with @Steejay can we try 'Lucida Console' instead of 'Courier New'? Here's the comparison for reference:
_DEV__Superset
_DEV__Superset

@rusackas
Copy link
Member

Ugh... not again! ACE Editor is so painful with this issue, it seems to keep popping up like whack-a-mole. My general feelings on the issue are:

  • I'd hate to see Fira Code die off due to this bug (but I understand)
  • I fear if we use other platform-specific fonts (Menlo, etc) we'll see this continue to manifest itself in other ways.
  • I hope we can target altering just the bold words as Elizabeth suggests.

The way it calculates the position is just super error prone... I'm not sure if something like CodeMirror has all the features we need, but my temptation to dive into that rabbit hole is growing.

@etr2460
Copy link
Member

etr2460 commented Jan 14, 2021

@ktmud mentioned using the code editor that vscode uses a while back (https://github.com/microsoft/monaco-editor). If after 1.0.0 anyone wanted to do some tech debt cleanup/refactor, moving to Monaco editor might be reasonable

Edit: and here's a react wrapper: https://github.com/suren-atoyan/monaco-react

@eschutho
Copy link
Member

@ktmud mentioned using the code editor that vscode uses a while back (https://github.com/microsoft/monaco-editor). If after 1.0.0 anyone wanted to do some tech debt cleanup/refactor, moving to Monaco editor might be reasonable

Edit: and here's a react wrapper: https://github.com/suren-atoyan/monaco-react

Nice, we'll look into those options. Thanks @etr2460 and @rusackas for the feedback.

@betodealmeida
Copy link
Member Author

I hope we can target altering just the bold words as Elizabeth suggests.

@rusackas we talked with @Steejay and he recommended using a single font for the whole query.

@Steejay
Copy link

Steejay commented Jan 15, 2021

I think keeping the font consistent would be ideal especially if its within the same line.

@betodealmeida
Copy link
Member Author

stamping, could you also file an issue for the Safari UX bug?

#12565

@betodealmeida betodealmeida merged commit 39c6ef2 into apache:master Jan 15, 2021
villebro pushed a commit that referenced this pull request Jan 25, 2021
* fix: incorrect cursor position Firefox

* Use different font

* Fix lint

* Use Lucida Console
@rumbin rumbin mentioned this pull request Mar 27, 2021
@mapshen mapshen mentioned this pull request Jul 29, 2021
3 tasks
@MichaelHintz MichaelHintz mentioned this pull request Sep 7, 2022
3 tasks
@mistercrunch mistercrunch added 🍒 1.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 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-io size/XS v1.0.1 🍒 1.0.1 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants