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

bugfix: Make scrollToEnd to be more reliable #4498

Closed
wants to merge 1 commit into from

Conversation

mstahv
Copy link
Member

@mstahv mstahv commented Jan 10, 2023

Description

Fixes #4497

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@mstahv
Copy link
Member Author

mstahv commented Jan 10, 2023

Note that the current implementation seems very hacky and inefficient (causes extra roundtrips to server) to me, but with this change the method becomes at least functional for common usage.

@sonarcloud
Copy link

sonarcloud bot commented Jan 10, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell E 42 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@czp13
Copy link
Contributor

czp13 commented Jan 20, 2023

Is this related to the scrollToIndex() GridTree problem? It would be amazing if this could be fixed 🙏

@mstahv
Copy link
Member Author

mstahv commented Jan 23, 2023

It doesn't look like that. The scrollToEnd seems to have totally custom implementation. Do you have a link to the original issue in TreeGrid that you are facing?

@tomivirkki
Copy link
Member

Making scrollToIndex work reliably with TreeGrid would require some new API, see this discussion

@czp13
Copy link
Contributor

czp13 commented Jan 23, 2023

@mstahv: There are more tickets I assume, but I am aware of these ones:

Also, this same customer, who reported the above using extensively the TreeGrid, and experienced these ones on TreeGrid:

@tomivirkki: It would be quite nice to tackle some of these too with the new API.

Copy link
Contributor

@sissbruecker sissbruecker left a comment

Choose a reason for hiding this comment

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

Sorry for the late review. Not really happy with the setTimeout solution but I also couldn't find any alternatives.

Could you please add an integration test as mentioned in the contribution guidelines? GridScrollToPage would be a good place to start.

getUI().ifPresent(
ui -> ui.beforeClientResponse(this, ctx -> getElement()
.executeJs("this.scrollToIndex(this._effectiveSize)")));
getUI().orElseGet(UI::getCurrent).beforeClientResponse(this,
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using getElement().getNode().runWhenAttached to run the code when the component is actually added to a UI? There's a few other places in the component that use this approach.

.executeJs("this.scrollToIndex(this._effectiveSize)")));
getUI().orElseGet(UI::getCurrent).beforeClientResponse(this,
ctx -> getElement().executeJs(
"const el=this; setTimeout(()=>el.scrollToIndex(el._effectiveSize),0);"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"const el=this; setTimeout(()=>el.scrollToIndex(el._effectiveSize),0);"));
"setTimeout(() => this.scrollToIndex(this._effectiveSize));"));

@yuriy-fix
Copy link
Contributor

Closing the PR as stale as the last review comments have not been addressed in over a month. Please don't hesitate to open a new PR if you want to continue with this contribution. Thanks!

@yuriy-fix yuriy-fix closed this Jul 20, 2023
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.

Grid.scrollToEnd does not work if called before attaching
5 participants