react-component / react-component/table

Header scrollLeft set to 0 when adding a new column

Aperta
#699 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
1.4k
Fork
618
Merge medio
10h 19m
PR unite (30g)
2

Descrizione

code:
import React from 'react';
import Table from 'rc-table';
import '../../assets/index.less';

const columns = [
  { title: 'title1', dataIndex: 'a', key: 'a', width: 100 },
  { title: 'title2', dataIndex: 'b', key: 'b', width: 100 },
  { title: 'title3', dataIndex: 'c', key: 'c', width: 100 },
  { title: 'title4', dataIndex: 'b', key: 'd', width: 100 },
  { title: 'title5', dataIndex: 'b', key: 'e', width: 100 },
  { title: 'title6', dataIndex: 'b', key: 'f', width: 100 },
  { title: 'title7', dataIndex: 'b', key: 'g', width: 100 },
  { title: 'title8', dataIndex: 'b', key: 'h', width: 100 },
  { title: 'title9', dataIndex: 'b', key: 'i', width: 100 },
  { title: 'title10', dataIndex: 'b', key: 'j', width: 100 },
  { title: 'title11', dataIndex: 'b', key: 'k', width: 100 },
  { title: 'title12', dataIndex: 'b', key: 'l', width: 100 },
];

const data = [
  { a: '123', b: 'xxxxxxxx xxxxxxxx', d: 3, key: '1' },
  { a: 'cdd', b: 'edd12221 edd12221', d: 3, key: '2' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '3' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '4' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '5' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '6' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '7' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '8' },
  { a: '133', c: 'edd12221 edd12221', d: 2, key: '9' },
];

const Demo = () => {
  const [visible, setVisible] = React.useState(true);
  const [cols,setCols] = React.useState(columns);
  return (
    <div>
      <h2>Scroll X/Y</h2>
      <button
        type="button"
        onClick={() => {
          setVisible(!visible);
        }}
      >
        Trigger Visible
      </button>
      <button type='button' onClick={()=>{
        setCols((cols)=>{
          const newCols = [...cols];
          newCols.push({ title: `titleN`, dataIndex: 'b', key: `N`, width: 100 });
          return newCols;
        })
      }}>
        add column
      </button>
      <div style={{ display: visible ? undefined : 'none' }}>
        <Table
          useFixedHeader
          style={{ width: 800 }}
          scroll={{ x: 1500, y: 300 }}
          columns={cols}
          data={data}
        />
      </div>
    </div>
  );
};

export default Demo;
performance

https://user-images.githubusercontent.com/59195554/142131119-39a2e9de-a394-4083-b2a2-1edd70c02d3a.mov

expect

header and body remain the same position when adding a column

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione Demo fornita usando il componente Table, lo scorrimento orizzontale e l’azione di aggiunta di una colonna. Traccia come vengono gestite le posizioni di scorrimento dell’intestazione e del corpo quando cambiano le colonne, quindi verifica che l’aggiunta di una colonna lasci invariate entrambe le posizioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, react
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.