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 scrollbar issue in anki-editable component in two ways #1038

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

hgiesel
Copy link
Contributor

@hgiesel hgiesel commented Feb 23, 2021

This addresses what you mentioned here

  • Using :host-context(.nightMode) allows for applying the night mode
    scroll bar inside the component. :host-context seems to be particular suited for these theming issues, even the examples on Mozilla mention it. For this I moved the scrollbar CSS to its own file.

  • Apply max-width: 100% to all element within editable, not just images. You can still set a div to max-width: 20000px; width: 20000px;, in which case it will be bigger than the field, but the scrollbar will then be in night mode.

I've done some tests with tables, and it works very well. The table will be bigger than the field, only if necessary, and the scroll bars show up in the correct color.

- using :host-context(.nightMode) allows for applying the nightmode
  scroll bar inside the component
- apply max-width: 100% to all element within editable, not just images
@hgiesel hgiesel marked this pull request as draft February 23, 2021 15:02
@hgiesel hgiesel marked this pull request as ready for review February 23, 2021 15:10
@dae
Copy link
Member

dae commented Feb 24, 2021

Thanks Henrik!

It looks like Safari does not support host-context, so this code won't have any effect if it gets used in AnkiMobile in the future: https://caniuse.com/?search=host-context. That might not be a problem in this case, as the default scrollbar colours automatically follow the system theme on iOS. But something to bear in mind if you were planning to use host-context for other uses in the future.

@dae dae merged commit c9992e3 into ankitects:main Feb 24, 2021
@hgiesel
Copy link
Contributor Author

hgiesel commented Feb 24, 2021

It also seems like :host-context will never be supported in Safari. It seems like "styling hooks" are an adequate replacement.

@hgiesel hgiesel deleted the imgmaxwidth branch October 20, 2021 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants