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

Absolute positioned checkboxes overlay floated elements #26870

Merged
merged 13 commits into from Sep 30, 2023
Merged

Conversation

rafh
Copy link
Contributor

@rafh rafh commented Sep 1, 2023

Currently, checkboxes are positioned as absolute. This positioning causes the input to overlay an element that has been floated within the editor. Floated elements are useful if you want your text to wrap around this element. This PR fixes the overlaying of checkboxes by removing the absolute positioning, updating the ul padding, and displaying.task-list-item flex to ensure inputs and the associated label are on the same line.

Screenshots:

Before:
Screenshot 2023-09-01 at 3 40 59 PM

After:
Screenshot 2023-09-01 at 3 42 20 PM

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 1, 2023
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 1, 2023
@techknowlogick techknowlogick added type/bug topic/ui Change the appearance of the Gitea UI labels Sep 1, 2023
@silverwind
Copy link
Member

We need to be careful around markdown rendering to stay compatible with GitHub's rendering. Could you post your sample markdown document here so we can compare this and GitHub's solution (assuming they have fixed it).

@rafh
Copy link
Contributor Author

rafh commented Sep 4, 2023

Here's an example of my markdown. When an image is aligned left or right the following CSS is applied by GitHub

img[Attributes Style] {
    float: left;
    vertical-align: top;
    width: 200px;
}

  • example checkbox

Copy link
Contributor

@kdumontnu kdumontnu left a comment

Choose a reason for hiding this comment

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

For traceability, it looks likes this regression was introduced in #17395

I added a bit of a stress-test to compare and it looks like a marked improvement:

Here is some base text
- [ ] One
- [ ] 

<img align="left" width="300" height="200" src="https://gitea.com/assets/img/logo.svg">

- [ ] Two
- [ ] Three
- [ ] Four
- [ ] 

More text


#### dense list
- [ ] foo
- [ ] barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
- [ ] baz

#### not so dense list
- [ ] foo

- [ ] barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
- [ ] second item

- [ ] baz

image

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 5, 2023
@rafh
Copy link
Contributor Author

rafh commented Sep 6, 2023

This is the associated markdown for this comment:

<img  align="left" alt="" width="200" src="/assets/6152817/d0b0b99a-db2b-4b6d-946d-277bfd24fc11">
* [ ]   example checkbox

Here's an example of my markdown. When an image is aligned left or right the following CSS is applied by GitHub

img[Attributes Style] {
    float: left;
    vertical-align: top;
    width: 200px;
}
  • example checkbox

@@ -144,7 +144,7 @@

.markup ul,
.markup ol {
padding-left: 2em;
padding-left: 0;
Copy link
Contributor

@kdumontnu kdumontnu Sep 7, 2023

Choose a reason for hiding this comment

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

@rafh I'm worried about this style affecting other elements unrelated to checkboxes. Are there other markdown ul ol items this will apply to in markdown (I assume yes)?

Especially because this value was not changed here: https://github.com/go-gitea/gitea/pull/17411/files

(btw, this is an area front-end testing could validate)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kdumontnu I understand your point. Instead, we should change the em back to 2em and update the .task-list-item to have margin-left: -2em;. This will ensure that all checkboxes are aligned properly without impacting all ol and ul.

Here's an example of the markup and how it is rendered within Gitea.

- [x] example content

<img  align="left" alt="" width="200" src="https://user-images.githubusercontent.com/6152817/265531274-d0b0b99a-db2b-4b6d-946d-277bfd24fc11.jpg">

- [x] example content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed efficitur orci, eu cursus sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed efficitur orci, eu cursus sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed efficitur orci, eu cursus sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed efficitur orci, eu cursus sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed efficitur orci, eu cursus sapien.

<img style="clear: both" alt="" width="200" src="https://user-images.githubusercontent.com/6152817/265531274-d0b0b99a-db2b-4b6d-946d-277bfd24fc11.jpg">


- [ ] one

- [ ] two
Screenshot 2023-09-07 at 2 51 27 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like a reasonable solution to me, or maybe you can add a :not(.task-list-item) to the selectors above and. Whatever will apply the style to the .task-list-item items, but not change the styling for other lists.

Copy link
Contributor

@kdumontnu kdumontnu left a comment

Choose a reason for hiding this comment

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

See comment

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 7, 2023
Copy link
Contributor

@kdumontnu kdumontnu left a comment

Choose a reason for hiding this comment

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

Looks good - one minor thing below you might want to address is that the spacing between non-dense checkboxes is greater than spacing between non-dense list items (code below)

Screenshot 2023-09-12 at 2 28 57 PM
Here is some base text
- [ ] One
- [ ] 

- Bullet
- Items

<img align="left" width="300" height="200" src="https://gitea.com/assets/img/logo.svg">

- [ ] Two
- [ ] Three
- [ ] Four
- [ ] 

More text


#### dense list
- [ ] foo
- [ ] barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
- [ ] baz

#### not so dense list
- [ ] foo

- [ ] barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
- [ ] second item

- [ ] baz

<img align="left" width="300" height="200" src="https://gitea.com/assets/img/logo.svg">

- bullet
- items

Here is some base text

  • One

  • [ ]

  • Bullet

  • Items

  • Two
  • Three
  • Four
  • [ ]

More text

dense list

  • foo
  • barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
  • baz

not so dense list

  • foo

  • barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar

  • second item

  • baz

  • bullet
  • items

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Sep 12, 2023
@kdumontnu
Copy link
Contributor

@silverwind any other thoughts on this - seems like a clear improvement, and gets rid of the absolute positioning (which I'm sure is messing up some other rendering as well).

@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 14, 2023
@rafh
Copy link
Contributor Author

rafh commented Sep 22, 2023

This is how GitHub renders the following markdown and how Gitea renders (edited to show latest commit changes)

Gitea(left) - GitHub(right)
Group 19


- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur
 <img align="left" width="300" height="200" src="https://github.com/assets/6152817/d0b0b99a-db2b-4b6d-946d-277bfd24fc11">

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

#### dense list
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

 <img align="left" width="300" height="200" src="https://github.com/assets/6152817/d0b0b99a-db2b-4b6d-946d-277bfd24fc11">

#### not so dense list
- [ ] 1
- [ ] 2
- [ ] 3

Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

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

I trust @kdumontnu's words that all potential regressions have been fixed.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 27, 2023
@delvh delvh added the backport/v1.21 This PR should be backported to Gitea 1.21 label Sep 27, 2023
@wxiaoguang
Copy link
Contributor

I do no think this fix is right.

It breaks some more common layout like this:

* [ ] a
    * [ ] a1
    * [ ] a2
* [ ] b
* [ ] c
* [ ] d

----

* [ ] a
    * [ ] a1
    * [ ] a2

* [ ] b

image

@wxiaoguang wxiaoguang added the status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR label Sep 28, 2023
@kdumontnu
Copy link
Contributor

I do no think this fix is right.

It breaks some more common layout like this:

* [ ] a
    * [ ] a1
    * [ ] a2
* [ ] b
* [ ] c
* [ ] d

----

* [ ] a
    * [ ] a1
    * [ ] a2

* [ ] b

Thanks, good catch!

@silverwind
Copy link
Member

silverwind commented Sep 28, 2023

Can we as a first step copy GitHub's CSS exactly to reproduce their rendering, and then improve upon it by adding the margin-left to the checkboxes so they are not "glued" to the image?

@rafh
Copy link
Contributor Author

rafh commented Sep 29, 2023

Can we as a first step copy GitHub's CSS exactly to reproduce their rendering, and then improve upon it by adding the margin-left to the checkboxes so they are not "glued" to the image?

I've applied the styling used by GitHub. I added more padding to left-aligned images. Otherwise, our checkboxes would lie directly next to the images.

Below I've consolidated all the markdown examples and added one more example at the top (empty checkboxes). I added this because the previous code had the following comment and I wanted to ensure this edge case was covered.

to render a checkbox list without content - [ ], we need this min-height to make sure the <li> can be visible

Empty Checkboxes
- [ ] 
- [ ] 

--- 

* [ ] a
    * [ ] a1
    * [ ] a2
* [ ] b
* [ ] c
* [ ] d

----

* [ ] a
    * [ ] a1
    * [ ] a2

* [ ] b


- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

 <img align="left" width="300" height="200" src="https://github.com/assets/6152817/d0b0b99a-db2b-4b6d-946d-277bfd24fc11">

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

#### dense list
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur
- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam velit ac metus vulputate egestas. Etiam ut enim iaculis, egestas mauris ac, convallis ex. Curabitur

 <img align="left" width="300" height="200" src="https://github.com/assets/6152817/d0b0b99a-db2b-4b6d-946d-277bfd24fc11">

#### not so dense list
- [ ] 1
- [ ] 2
- [ ] 3


Here is some base text
- [ ] One
- [ ] 

- Bullet
- Items

<img align="left" width="300" height="200" src="https://gitea.com/assets/img/logo.svg">

- [ ] Two
- [ ] Three
- [ ] Four
- [ ] 

More text


#### dense list
- [ ] foo
- [ ] barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
- [ ] baz

#### not so dense list
- [ ] foo

- [ ] barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbarbar barbarbarbarbarbarbar barbarbarbarbar
- [ ] second item

- [ ] baz

<img align="left" width="300" height="200" src="https://gitea.com/assets/img/logo.svg">

- bullet
- items

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 30, 2023
@lunny lunny removed the status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR label Sep 30, 2023
@lunny lunny enabled auto-merge (squash) September 30, 2023 09:10
@lunny lunny merged commit 4cb51cb into go-gitea:main Sep 30, 2023
26 checks passed
@GiteaBot GiteaBot added this to the 1.22.0 milestone Sep 30, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Sep 30, 2023
Currently, checkboxes are positioned as absolute. This positioning
causes the input to overlay an element that has been floated within the
editor. Floated elements are useful if you want your text to wrap around
this element. This PR fixes the overlaying of checkboxes by removing the
absolute positioning, updating the `ul` padding, and
displaying`.task-list-item` `flex` to ensure inputs and the associated
label are on the same line.

Screenshots:

Before:
<img width="762" alt="Screenshot 2023-09-01 at 3 40 59 PM"
src="https://github.com/go-gitea/gitea/assets/6152817/570247c7-7f5c-4697-bfc9-ad4655e37991">

After:
<img width="762" alt="Screenshot 2023-09-01 at 3 42 20 PM"
src="https://github.com/go-gitea/gitea/assets/6152817/db53df45-1294-4eee-84c0-b21ac4fdf805">

---------

Co-authored-by: rafh <rafaelheard@gmail.com>
@GiteaBot GiteaBot added backport/done All backports for this PR have been created and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Sep 30, 2023
6543 pushed a commit that referenced this pull request Sep 30, 2023
)

Backport #26870 by @rafh

Currently, checkboxes are positioned as absolute. This positioning
causes the input to overlay an element that has been floated within the
editor. Floated elements are useful if you want your text to wrap around
this element. This PR fixes the overlaying of checkboxes by removing the
absolute positioning, updating the `ul` padding, and
displaying`.task-list-item` `flex` to ensure inputs and the associated
label are on the same line.

Screenshots:

Before:
<img width="762" alt="Screenshot 2023-09-01 at 3 40 59 PM"
src="https://github.com/go-gitea/gitea/assets/6152817/570247c7-7f5c-4697-bfc9-ad4655e37991">

After:
<img width="762" alt="Screenshot 2023-09-01 at 3 42 20 PM"
src="https://github.com/go-gitea/gitea/assets/6152817/db53df45-1294-4eee-84c0-b21ac4fdf805">

Co-authored-by: Rafael Heard <rafael.heard@gmail.com>
Co-authored-by: rafh <rafaelheard@gmail.com>
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. outdated/theme/markdown size/S Denotes a PR that changes 10-29 lines, ignoring generated files. topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants