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 displaying font family in the editor #2831

Merged
merged 6 commits into from
Jul 18, 2019
Merged

Conversation

miina
Copy link
Contributor

@miina miina commented Jul 17, 2019

Fixes #2828.
Fixes #2838.
Fixes #2839.

@miina miina requested a review from swissspidy July 17, 2019 20:22
@googlebot googlebot added the cla: yes Signed the Google CLA label Jul 17, 2019
@swissspidy
Copy link
Collaborator

Thanks for providing such a quick fix!

Seems like quite a few selectors to remove. I'll try to dome some in-depth testing to see whether this causes any other issues.

Also, note to self that we could add some E2E test for the font family selection feature.

@miina
Copy link
Contributor Author

miina commented Jul 17, 2019

It looked like .editor-styles-wrapper could replace all the other selectors.

I'll try to dome some in-depth testing to see whether this causes any other issues.

Thanks, tried to test it myself, too, always good to have someone else testing though.

Also, note to self that we could add some E2E test for the font family selection feature.

Yep, would be good to take the e2e tests into the dev process, I'm def happy to add some tests post-merge, also for the existing stuff. If I understand correctly then you already started within #2708.

@swissspidy
Copy link
Collaborator

Sounds great! Yeah started the basic e2e test setup in #2708 and now I‘d like to bring some structure and prioritization into this. See #2795

@swissspidy swissspidy mentioned this pull request Jul 18, 2019
22 tasks
Copy link
Collaborator

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

Now all the fonts in the editor are serif:

Screenshot 2019-07-18 at 10 54 12
Screenshot 2019-07-18 at 10 54 05

At least the text block's font family properly changes though, so there's that :)

@miina
Copy link
Contributor Author

miina commented Jul 18, 2019

Hopefully works now. Tested the following:

  • Correct font family in the editor.
  • On refresh doesn't display Update button as active (font calculation is working OK)
  • Font family changes display in the editor.

@miina miina requested a review from swissspidy July 18, 2019 09:20
@swissspidy
Copy link
Collaborator

Looks better now.

Sorry for hijacking your PR, but I felt like this is a good opportunity to fix the block dimension and font size calculation. See 1187d73. Because right now font family changes are not being considered in these cases.

There's only one problem at the moment:

  1. Create new text block with "Hello World"
  2. Turn off fit-text
  3. Change font family to Lucida Sans Typewriter
  4. Text wraps on second line in the editor.
  5. However, on the frontend it's all on one line.

Not sure why that is at the moment. I thought #2809 would fix that?

@swissspidy
Copy link
Collaborator

Not sure why that is at the moment.

Actually, when browsing the frontend in a 328x553 view, it looks the same. Just not in something like a 375x812 view.

@miina
Copy link
Contributor Author

miina commented Jul 18, 2019

Actually, when browsing the frontend in a 328x553 view, it looks the same. Just not in something like a 375x812 view.

Then it should be OK, since the values are in % then we can't really control it beyond ensuring it looks the same with the same width/height.

@swissspidy
Copy link
Collaborator

Cool. If you can test my change too that would be excellent. Then we can merge and send it to QA.

} = attributes;

const checkFontSize = (
const checkFontSize = ampFitText && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ This check is actually already within maybeUpdateFontSize but I guess it doesn't harm to have it here + makes it more clear/readable, too.

@miina
Copy link
Contributor Author

miina commented Jul 18, 2019

Seems to work well most of the time.

For some reason, sometimes with amp-fit-text it doesn't work properly, not sure why. Did the following:

  • Added a text block with "Another test!" written in it.
  • Started clicking through the fonts from top to bottom.
  • In some cases, it didn't adjust the font size and the text went over the limits.

Note that this happened maybe once in clicking through the whole set of fonts so it's not something really easy to debug, we can probably look into this later if it should appear more, let's merge this.

@miina
Copy link
Contributor Author

miina commented Jul 18, 2019

Also found this issue: #2839

Testing shows that happens on develop, too, so unrelated to the PR. Looking into it

@swissspidy
Copy link
Collaborator

For some reason, sometimes with amp-fit-text it doesn't work properly, not sure why.

I think this might be a race condition when the font stylesheet hasn't loaded yet, so the calculation does nothing because the font hasn't been applied.

@swissspidy
Copy link
Collaborator

Also found this issue: #2839

I think it's an easy fix. Let me push something really quick.

@swissspidy
Copy link
Collaborator

f2e7a5e also fixes a bug where a text block with turned off fit-text does not resize when writing a long text.

With this change, the story title block correctly changes font size or dimensions during typing of a very long title.

@miina
Copy link
Contributor Author

miina commented Jul 18, 2019

LGTM!

@swissspidy swissspidy merged commit 4ded04b into develop Jul 18, 2019
@swissspidy swissspidy deleted the fix/2828-font_family branch July 18, 2019 12:58
@swissspidy swissspidy added this to the v1.2.1 milestone Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
3 participants