Skip to content

Repeater: Tab Flickering and Form State Loss on Tab Switch #52

@jerico-juegos

Description

@jerico-juegos

Summary: Switching between tabs in the repeater layout causes flickering and loss of form state due to React unmounting/remounting behavior. This affects user experience and data entry reliability.

The original implementation renders only the active tab content:

{ items[ activeItem ] &&
  <Content
    key={ items[ activeItem ].key ?? activeItem }
    className='tf-repeater-tab-content'
  >
    { rowFields.map((control, i) => (
      <Row key={ control.name ?? i } className='tf-repeater-tab-row'>
        { renderItem(control, items[ activeItem ], activeItem) }
      </Row> )) }
  </Content> }

I tested rendering all tabs and toggling visibility via display: none.

Changes Tested Locally: assets/src/components/repeater/layout/tab/Tab.jsx

{ items && items.map((item, itemIndex) => (
  <Content
    key={ item.key ?? itemIndex }
    className='tf-repeater-tab-content'
    style={{ display: activeItem === itemIndex ? 'block' : 'none' }}
  >
    { rowFields.map((control, i) => (
      <Row key={ control.name ?? i } className='tf-repeater-tab-row'>
        { renderItem(control, item, itemIndex) }
      </Row> )) }
  </Content>
)) }

assets/src/components/base/tab/Tab.jsx

const Content = props => (
  <div 
    className={ 'tf-tab-content ' + (props.className ?? '') }
    style={ props.style }
  >
    { props.children }
  </div>
)

Observed Behavior After Patch:

  • No flickering when switching tabs
  • Input fields retain focus and values
  • DOM remains stable

Questions:

  • Is this a viable long-term solution?
  • Are there performance concerns with rendering all tab contents?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions