Select to view content in your preferred language

ItemSelector component doesn't work properly if height isn't set to pixels

222
2
Jump to solution
04-22-2025 12:36 PM
KenBuja
MVP Esteemed Contributor

I'm using the ItemSelector in my custom widget (v1.17), but I'm having difficulty getting it to work correctly. I want to have the simple list in a SidePopper along with a button to accept the choice. This code

     <SidePopper
        position="right"
        title="Template Layer"
        isOpen={showSidePopper && !urlUtils.getAppIdPageIdFromUrl().pageId}
        toggle={onCloseSidePopper}
        trigger={sidePopperTrigger?.current}
      >
       <div className="d-flex flex-column">
          <div className='data-item-search'>
            <ItemSelector
              itemType={SupportedItemTypes.FeatureService}
              portalUrl={portal.url}
              mode={ItemSelectorMode.Simple}
              onSelect={onItemSelect}
              onRemove={onItemRemove}
              selectedItems={selectedItems}
            ></ItemSelector>
          </div>
          </div className="d-flex justify-content-center">
            <Button
              variant='contained'
              color='primary'
              onClick={onDoneClicked}
              disabled={selectedTemplateItem == null}
            >
              Done
            </Button>
        </div>
      </SidePopper>

will give me a list of 18 items. The list doesn't add more items as I scroll down and regardless of what I put in the Search box, I get a maximum of 18 entries. 

I've tried a variety of classNames, but nothing seems to work. Only if I add an explicit height in pixels (percentage doesn't work either) will I get a list that adds more items as I scroll down. 

          <div className="data-item-search" style={{ height: '500px' }}>
            <ItemSelector
              itemType={SupportedItemTypes.FeatureService}
              portalUrl={portal.url}
              mode={ItemSelectorMode.Simple}
              onSelect={onItemSelect}
              onRemove={onItemRemove}
              selectedItems={selectedItems}
            ></ItemSelector>
          </div>

Obviously, this isn't responsive. What's the proper way to style this component and the button to make it fill the SidePopper?

0 Kudos
1 Solution

Accepted Solutions
Allen_Zhang
Frequent Contributor

Hi @KenBuja . Try this: add h-100 to the parent div, add flex-grow-1 to the item selector div, and add flex-shrink-0 to the button div. 

      <SidePopper
        position="right"
        title="Template Layer"
        isOpen={showSidePopper && !urlUtils.getAppIdPageIdFromUrl().pageId}
        toggle={onCloseSidePopper}
        trigger={sidePopperTrigger?.current}
      >
       <div className="d-flex flex-column h-100">
          <div className='data-item-search flex-grow-1'>
            <ItemSelector
              itemType={SupportedItemTypes.FeatureService}
              portalUrl={portal.url}
              mode={ItemSelectorMode.Simple}
              onSelect={onItemSelect}
              onRemove={onItemRemove}
              selectedItems={selectedItems}
            ></ItemSelector>
          </div>
          </div className="d-flex justify-content-center flex-shrink-0">
            <Button
              variant='contained'
              color='primary'
              onClick={onDoneClicked}
              disabled={selectedTemplateItem == null}
            >
              Done
            </Button>
        </div>
      </SidePopper>

 

View solution in original post

0 Kudos
2 Replies
Allen_Zhang
Frequent Contributor

Hi @KenBuja . Try this: add h-100 to the parent div, add flex-grow-1 to the item selector div, and add flex-shrink-0 to the button div. 

      <SidePopper
        position="right"
        title="Template Layer"
        isOpen={showSidePopper && !urlUtils.getAppIdPageIdFromUrl().pageId}
        toggle={onCloseSidePopper}
        trigger={sidePopperTrigger?.current}
      >
       <div className="d-flex flex-column h-100">
          <div className='data-item-search flex-grow-1'>
            <ItemSelector
              itemType={SupportedItemTypes.FeatureService}
              portalUrl={portal.url}
              mode={ItemSelectorMode.Simple}
              onSelect={onItemSelect}
              onRemove={onItemRemove}
              selectedItems={selectedItems}
            ></ItemSelector>
          </div>
          </div className="d-flex justify-content-center flex-shrink-0">
            <Button
              variant='contained'
              color='primary'
              onClick={onDoneClicked}
              disabled={selectedTemplateItem == null}
            >
              Done
            </Button>
        </div>
      </SidePopper>

 

0 Kudos
KenBuja
MVP Esteemed Contributor

Unfortunately, that didn't work either. The ItemSelector would now add items as I scrolled down, but the div was still too long for the SidePopper.

However, it was close. This is what finally worked for me

      <SidePopper
        position="right"
        title="Template Layer"
        isOpen={showSidePopper && !urlUtils.getAppIdPageIdFromUrl().pageId}
        toggle={onCloseSidePopper}
        trigger={sidePopperTrigger?.current}
      >
        <div className="d-flex flex-column h-100">
          <div className="data-item-search flex-grow-1 h-75">
            <ItemSelector
              itemType={SupportedItemTypes.FeatureService}
              portalUrl={portal.url}
              mode={ItemSelectorMode.Simple}
              onSelect={onItemSelect}
              onRemove={onItemRemove}
              selectedItems={selectedItems}
            ></ItemSelector>
          </div>
          <div className="d-flex justify-content-center mb-2">
            <Button
              variant="contained"
              color="primary"
              onClick={onDoneClicked}
              disabled={selectedTemplateItem == null}
            >
              Done
            </Button>
          </div>
        </div>
      </SidePopper>

 

0 Kudos