Code Monkey home page Code Monkey logo

Comments (8)

sja-cslab avatar sja-cslab commented on June 20, 2024 2

There are no requirements. With that second div, without flex you just broke the width/height calculation within the Virtual Scroller. Mixing never is a good thing i guess.

from primereact.

melloware avatar melloware commented on June 20, 2024 1

@sja-cslab thank you! Will close this as "workaround provided" as you are right this is more to do with the structure of this HTML.

from primereact.

sja-cslab avatar sja-cslab commented on June 20, 2024

Your second div.flex-1 is redundant and causes this.
Remove that and your Scroll will work.

If you really want that second div you've to keep flex behavior down the tree like

<div className="h-full flex">
      <div className="flex flex-auto">
        <DataTable
        className="flex-auto"
          value={DATA}
          dataKey="id"
          scrollable
          size="small"
          scrollHeight="flex"
          virtualScrollerOptions={VIRTUAL_SCROLLER_OPTIONS}
        >
          <Column field="id" header="ID" />
        </DataTable>
      </div>
</div>

from primereact.

inad9300 avatar inad9300 commented on June 20, 2024

If there are requirements for the HTML surrounding DataTable, could they be documented?

from primereact.

melloware avatar melloware commented on June 20, 2024

@inad9300 what he is saying is your HTML + CSS broke the table styling. So like anything else in HTML/CSS you would have to respect the structure of the DOM of the generated component.

from primereact.

inad9300 avatar inad9300 commented on June 20, 2024

If "without flex [I] just broke the width/height calculation within the Virtual Scroller", it follows that there is a requirement to "use HTML and CSS that does not break the width/height calculation within the Virtual Scroller", and it would be good to know what the Virtual Scroller requires.

The reproducer I provided differs from my original code, which I iteratively simplified until I couldn't reproduce the problem anymore. In order to apply the solution to my real case, I would like to have a somewhat solid understanding of the constraints imposed by Virtual Scroller over layout and styling.

Lastly, but importantly, after closer inspection of your proposed solution (other than removing the div, which I don't yet see any good reason to), it omits a crucial point from the original solution: flex-column. If you add it back, the scroll will remain broken; propagating "flex" is not the answer.

My suspicion is that the aforementioned calculations by Virtual Scroller just fail in one or a few corner cases that need to be taken into account (or documented).

from primereact.

sja-cslab avatar sja-cslab commented on June 20, 2024

@inad9300 I understand your point, and I apologize for not being more precise. However, in my opinion, we need a reproducer that causes your problem and closely resembles your specific case as much as possible. The workaround label is set here because you can utilize that workaround in the given reproducer.

The "good reason to" is simply that this adds one more level to the Dom-Tree, which isn't necessary here.

@melloware I've just tried to dig into this, but the calculation within scroll events in the Virtual Scroller appears to be correct. One point I couldn't figure out in those few minutes is that it seems like the whole thing is rerendered. After reaching a specific position while scrolling (when isRangeChanged is true for the first time), the scroll event triggers again with event.target.scrollTop === 0. I don't know if you or anyone else wants to dig deeper into this!?

To both:
I've just tried to reproduce that on my current project but was not able to. It has to be something with that specific dom/style combination.

from primereact.

inad9300 avatar inad9300 commented on June 20, 2024

(I agree keeping things simple is a good reason to remove the div, it just is a reason unrelated to the problem at hand.)

from primereact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.