javascript - Form disable the overflow - Stack Overflow

I try to implement an overflow in Form react-router, that's work in a classic <div><div&

I try to implement an overflow in Form react-router, that's work in a classic <div></div> but when I use <Form></Form> my overflow doesn't work. I don't find any topic who talk about that.

The context is a Remix app who use import { Form } from 'react-router'. I'm using React-Router v7.

Working example:

<div>
  <div style={{ overflowY: "auto" }}>
    <div>Truc</div>
    <div>Truc</div>
    .../...
    <div>Truc</div>
  </div>
</div>

Non-working example:

<Form>
  <div style={{ overflowY: "auto" }}>
    <div>Truc</div>
    <div>Truc</div>
    .../...
    <div>Truc</div>
  </div>
</Form>

Is it a bug, or Form cannot work with the overflow, or there is a trick for this case? All the other style work except the overflow rule.

I try to implement an overflow in Form react-router, that's work in a classic <div></div> but when I use <Form></Form> my overflow doesn't work. I don't find any topic who talk about that.

The context is a Remix app who use import { Form } from 'react-router'. I'm using React-Router v7.

Working example:

<div>
  <div style={{ overflowY: "auto" }}>
    <div>Truc</div>
    <div>Truc</div>
    .../...
    <div>Truc</div>
  </div>
</div>

Non-working example:

<Form>
  <div style={{ overflowY: "auto" }}>
    <div>Truc</div>
    <div>Truc</div>
    .../...
    <div>Truc</div>
  </div>
</Form>

Is it a bug, or Form cannot work with the overflow, or there is a trick for this case? All the other style work except the overflow rule.

Share Improve this question edited Mar 13 at 16:36 Drew Reese 204k18 gold badges245 silver badges273 bronze badges asked Mar 13 at 15:49 KnupelKnupel 3732 silver badges15 bronze badges 2
  • It might depend on your DOM structure and applied CSS. In the second code example you are basically inserting a form element between the divs. Can you create a running CodeSandbox demo of the code you are working with that reproduces the issue that readers could inspect live? – Drew Reese Commented Mar 13 at 15:55
  • I try to create a code to explain in codesandbox.io/p/sandbox/zmpcjr?file=%2Fsrc%2FApp.tsx%3A17%2C12 but I cannot set Form like I want because I4m not the main coder in the project and I don't understand well how Form work – Knupel Commented Mar 13 at 18:24
Add a comment  | 

1 Answer 1

Reset to default 0

When you insert Form between the div container that enforces a static height and the div container that should apply any overflow rules it breaks the abstraction between the divs because it (Form) hasn't any intrinsic height property.

Either push Form up the ReactTree to wrap the div elements:

<div className="App">
  <Form>
    <div style={{ height: "150px", backgroundColor: "red" }}>
      <div
        style={{
          height: "100%",
          overflowY: "auto",
          display: "flex",
          flexDirection: "column",
        }}
      >
        ...
      </div>
    </div>
  </Form>
</div>

Or push Form down the ReactTree under the div parent-child pairing:

<div className="App">
  <div style={{ height: "150px", backgroundColor: "red" }}>
    <div
      style={{
        height: "100%",
        overflowY: "auto",
        display: "flex",
        flexDirection: "column",
      }}
    >
      <Form>
        ...
      </Form>
    </div>
  </div>
</div>

Or alternatively you can tell the Form component to inhabit 100% of the height of its parent div element so the child div element has a height property to overflow in.

<div className="App">
  <div style={{ height: "150px", backgroundColor: "red" }}>
    <Form style={{ height: "100%" }}>
      <div
        style={{
          height: "100%",
          overflowY: "auto",
          display: "flex",
          flexDirection: "column",
        }}
      >
        ...
      </div>
    </Form>
  </div>
</div>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744692620a4588299.html

相关推荐

  • javascript - Form disable the overflow - Stack Overflow

    I try to implement an overflow in Form react-router, that's work in a classic <div><div&

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>