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 wrong bounding box for text line in block #144

Merged
merged 2 commits into from
Jul 21, 2023

Conversation

Amir-P
Copy link
Member

@Amir-P Amir-P commented Jun 21, 2023

Fixes #143 and changes hit test in text line to prevent trailing empty space from triggering rich text hit test.

Before:

Screenshot 2023-06-21 at 09 24 29

After:

Screenshot 2023-07-19 at 10 21 29

@Amir-P Amir-P requested a review from amantoux June 21, 2023 06:00
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Merging #144 (bce3a87) into master (3590e3d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #144   +/-   ##
=======================================
  Coverage   84.01%   84.02%           
=======================================
  Files          60       60           
  Lines        9348     9351    +3     
=======================================
+ Hits         7854     7857    +3     
  Misses       1494     1494           
Impacted Files Coverage Δ
...kages/fleather/lib/src/rendering/editable_box.dart 51.26% <100.00%> (-0.41%) ⬇️
...fleather/lib/src/rendering/editable_text_line.dart 71.80% <100.00%> (+0.30%) ⬆️

@amantoux
Copy link
Member

@Amir-P I think this break the behavior designed in PR #77

@Amir-P
Copy link
Member Author

Amir-P commented Jun 21, 2023

@Amir-P I think this break the behavior designed in PR #77

Can't we address that issue when hit testing? Also why it's not a problem with outside of block text lines? @amantoux

@amantoux
Copy link
Member

@Amir-P I think this break the behavior designed in PR #77

Can't we address that issue when hit testing? Also why it's not a problem with outside of block text lines? @amantoux

Hey @Amir-P, were you able to dig a little further on this?

@Amir-P
Copy link
Member Author

Amir-P commented Jun 27, 2023

Hey @Amir-P, were you able to dig a little further on this?

Not yet. I'll get to it tomorrow. Will let you know. @amantoux

@Amir-P
Copy link
Member Author

Amir-P commented Jul 4, 2023

There is definitely a problem with hit testing but the fix at #77 is only solving problem for blocks and causes another issue (#143). We need to merge this and then find a way for fixing underlying problem. WDYT? @amantoux

A normal text line with link on master branch showing the hit test problem:

Screenshot 2023-07-04 at 09 48 21

Update:

After testing RichText widget expanded horizontally, I found out that this behavior is from RichText widget.

RichText(
  text: TextSpan(children: [
    TextSpan(text: 'Test'),
    TextSpan(text: 'with'),
    TextSpan(
        text: 'Link',
        mouseCursor: SystemMouseCursors.click,
        recognizer: TapGestureRecognizer()
          ..onTap = () {
            print('Tap');
          }),
  ]),
);
Screenshot 2023-07-04 at 10 50 22
RichText(
  text: TextSpan(children: [
    TextSpan(text: 'Test'),
    TextSpan(text: 'with'),
    TextSpan(
        text: 'Link',
        mouseCursor: SystemMouseCursors.click,
        recognizer: TapGestureRecognizer()
          ..onTap = () {
            print('Tap');
          }),
  ]),
);
Screenshot 2023-07-04 at 10 52 18

This is a weird behavior to me. I think we have two options now:

  1. Extend RichText and fix the hitTest problem
  2. Limit the bounding box for both lines and blocks and fix problem with alignment and possibly other attributes that gets affected by limited bounding box.

@amantoux
Copy link
Member

amantoux commented Jul 6, 2023

@Amir-P Either solution works but if 2. is easily acheivable, I think we should go for this one

@Amir-P
Copy link
Member Author

Amir-P commented Jul 6, 2023

@Amir-P Either solution works but if 2. is easily acheivable, I think we should go for this one

Yeah, after experimenting with RichText and TextPainter, changes for option 1 is a lot. I think option 2 is safer. I'll push another commit on this branch to make lines bounding box like blocks and will update the issue description too. Then will fix the alignment issue.

@Amir-P Amir-P changed the title Fix wrong bounding box for text line in block Make bounding box for text line and text box same Jul 19, 2023
@Amir-P Amir-P changed the title Make bounding box for text line and text box same Fix wrong bounding box for text line in block Jul 19, 2023
@Amir-P Amir-P force-pushed the fix/wrong_line_bounding_box_in_block branch from 8cfe749 to 5d21ad4 Compare July 19, 2023 11:58
@Amir-P
Copy link
Member Author

Amir-P commented Jul 19, 2023

Finally, I've decided to keep text lines constraints unchanged and instead check if hit test position is in text boxes. I think it's ready for review. @amantoux

Copy link
Member

@amantoux amantoux left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @Amir-P

@amantoux amantoux merged commit ada3b68 into master Jul 21, 2023
4 checks passed
@Amir-P Amir-P deleted the fix/wrong_line_bounding_box_in_block branch July 21, 2023 09:17
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.

Different bounding box for text line and box
2 participants