Skip to content

refactor: visibility observer #74

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chintankavathia
Copy link
Member

use ResizeObserver api to emit visibility change. Also auto recalculate table when table resize by parent containers.

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

What is the new behavior?

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@chintankavathia chintankavathia force-pushed the refactor/visibility-observer branch 2 times, most recently from b130407 to 5268ad7 Compare July 9, 2024 11:02
@chintankavathia chintankavathia force-pushed the refactor/visibility-observer branch from 5268ad7 to 6de5892 Compare July 23, 2024 10:09
@chintankavathia chintankavathia marked this pull request as draft July 24, 2024 06:02
@chintankavathia chintankavathia force-pushed the refactor/visibility-observer branch from 6de5892 to c665207 Compare August 6, 2024 07:02
@chintankavathia chintankavathia marked this pull request as ready for review August 6, 2024 07:04
@chintankavathia
Copy link
Member Author

@timowolf Could you please review this?

@fh1ch fh1ch added the enhancement New feature or request label Sep 10, 2024
@fh1ch fh1ch requested review from fh1ch and timowolf September 10, 2024 12:48
Copy link
Member

@fh1ch fh1ch left a comment

Choose a reason for hiding this comment

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

@chintankavathia thanks a lot for the MR 🙇

Just one question from my end, the implementation itself looks a-ok from my end.

Comment on lines +471 to +488
/**
* Throttle time in ms. Will recalculate table this time after the resize.
*/
@Input() resizeThrottle = 100;

/**
* Emits first visibility change immediately without waiting for resizeThrottle.
*/
@Input() emitInitial = true;

Copy link
Member

Choose a reason for hiding this comment

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

Since the current/new behavior is not filled in within the MR template, would you mind commenting on why we should expose those values? I'm personally afraid that this just leads to non-aligned behavior across users and starts introducing issues. The input description also doesn't guide users to what values they should exactly use. I would therefore just pick sane defaults and not yet expose them to the end user, doing so only after we have a concrete need.

Copy link
Member Author

Choose a reason for hiding this comment

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

@fh1ch currently we have siResizeObserver as part of our internal Element lib which is being used with datatable by consumers manually to trigger recalculate (people often forgets to do this and end up with issues). Goal of the MR is to remove that manual need however since siResizeObserver also allows these two props I am exposing the same here to keep it compatible with what we have today with siResizeObserver.

Copy link
Member

Choose a reason for hiding this comment

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

@chintankavathia thanks a lot for the reply 🙇

@spike-rabbit thanks also for your comment. I do agree that we should probably wait with this one a bit, so we can address the resize events holistically. To quickly outline my concerns with the current approach:

  1. Consumers had to handle the resize event on their own so far and trigger the recalculation "manually". If we now suddenly handle this internally we create two trigger sources, which can be problematic if we consider performance. I therefore think this should be treated as a breaking change, so consumers are aware of it and can remove the overhead code on their end.
  2. Even if the internal siResizeObserver directive did offer inputs like resizeThrottle and emitInitial, I don't think that we need API compatibility since users anyway have to manually migrate (see point 1) and they also don't really make a lot of sense in the context of the datatable (especially the later).

Hence my point that we probably shouldn't integrate them from the get-go. Feel free to share your opinion here, but as said by @spike-rabbit, we can also discuss this once we rework the resize events all-together.

use `ResizeObserver` api to emit visibility change. Also auto recalculate table when table resize by parent containers.
@chintankavathia chintankavathia force-pushed the refactor/visibility-observer branch from c665207 to 5111072 Compare September 26, 2024 07:08
@fh1ch fh1ch requested a review from spike-rabbit March 24, 2025 11:17
@spike-rabbit
Copy link
Member

I would like to postpone this for a while. I see chances, that we may can get rid of listening to resize events completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants