question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AutocompleteList hidden by AccordionPanel

See original GitHub issue

I’m using the latest version of this library and this is happening.

// Structure
// TagInputAutocomplete renders the autocomplete fields with creeatable


.... really big form ...
<AccordionPanel>
                <VStack spacing={4} alignItems="flex-start">
                  <TagInputAutocomplete
                    name={`jobs.${index}.jobSkills`}
                    label="Job skills"
                    mappedValues={['react', 'node', 'typescript']}
                  />

                  <TagInputAutocomplete
                    name={`jobs.${index}.jobTools`}
                    label="Job tools"
                    mappedValues={[]}
                  />
                </VStack>
 </AccordionPanel>

...

TaginputAutocomplete

import { FormControl, FormLabel } from '@chakra-ui/react'
import {
  AutoComplete,
  AutoCompleteCreatable,
  AutoCompleteInput,
  AutoCompleteItem,
  AutoCompleteList,
  AutoCompleteTag
} from '@choc-ui/chakra-autocomplete'
import { NextPage } from 'next'
import { Controller, FieldPath, useFormContext } from 'react-hook-form'
import { TNewProjectFormData } from '../newProjectForm.zod'

type Props = {
  name: FieldPath<TNewProjectFormData>
  label: string
  mappedValues: string[]
}

const SkillsTagInput: NextPage<Props> = ({ name, label, mappedValues }) => {
  const { control } = useFormContext<TNewProjectFormData>()

  return (
    <Controller
      name={name}
      control={control}
      render={({ field }) => (
        <FormControl>
          <FormLabel htmlFor={field.name}>{label}</FormLabel>

          <AutoComplete openOnFocus multiple creatable onChange={field.onChange}>
            <AutoCompleteInput ref={field.ref} id={field.name}>
              {({ tags }) =>
                tags.map((tag, tid) => (
                  <AutoCompleteTag key={tid} label={tag.label} onRemove={tag.onRemove} />
                ))
              }
            </AutoCompleteInput>

            {mappedValues.length > 0 && (
              <AutoCompleteList>
                {mappedValues.map((value, cid) => (
                  <AutoCompleteItem
                    key={`option-${cid}`}
                    value={value}
                    textTransform="capitalize"
                    _selected={{ bg: 'whiteAlpha.50' }}
                    _focus={{ bg: 'whiteAlpha.100' }}
                  >
                    {value}
                  </AutoCompleteItem>
                ))}
              </AutoCompleteList>
            )}
            <AutoCompleteCreatable />
          </AutoComplete>
        </FormControl>
      )}
    />
  )
}

export default SkillsTagInput

Rendered form

Screen Shot 2022-06-23 at 23 26 03

Any suggestion or correction on the component structure will be helpful.

Feature Request

Add an usePortal prop, similar to chakra-dayzed-datepicker

Screen Shot 2022-06-23 at 23 28 29

As seen the calendar component hides anything behind it by using the usePortal prop

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SheaBelskycommented, Aug 5, 2022

I was able to get around this by manually implementing a portal, then conditionally rendering the element within the panel based on whether or not it was expanded!

const accordionItemRef = useRef();

return (
  <Accordion allowToggle>
    <AccordionItem>whatever</AccordionItem>
    <AccordionItem ref={accordionItemRef}>
      {({ isExpanded }) => (
        <Fragment>
          <h2>
            <AccordionButton>
              <Box flex="1" fontSize="18px" fontWeight="bold" textAlign="left">
                Accordion Item
              </Box>
              <AccordionIcon />
            </AccordionButton>
          </h2>
          <AccordionPanel>
            <Portal containerRef={accordionItemRef}>
              {isExpanded && <>{/* dropdown goes here */}</>}
            </Portal>
          </AccordionPanel>
        </Fragment>
      )}
    </AccordionItem>
  </Accordion>
);

0reactions
SpencerKaisercommented, Aug 23, 2022

I just had a very similar issue with Tabs… when I used isLazy it immediately began functioning again and the list started rendering once more. No idea why, but figured that might be meaningful to add the conversation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · anubra266/choc-autocomplete - GitHub
AutoCompleteList fails to display when parent is pre-rendered. #156 opened on Aug 22 by SpencerKaiser ... AutocompleteList hidden by AccordionPanel.
Read more >
Constant Field Values (primefaces 3.4 API)
Constant Field Values ; public static final String · INACTIVE_TAB_CONTENT_CLASS, "ui-accordion-content ui-helper-reset ui-widget-content ui-helper-hidden".
Read more >
Hiding the first tab of accordion panel in JSF Primefaces
By default the first tab of the primefaces accordion panel is shown open on page load. Is there a way that it can...
Read more >
Constant Field Values (PrimeFaces 11.0.0-RC2 API) - javadoc.io
org.primefaces.component.accordionpanel. ... public static final String · CONTAINER_CLASS, "ui-accordion ui-widget ui-helper-reset ui-hidden-container".
Read more >
City of Charlotte accessibility audit report
<label> be visually-hidden, ensure that it is still available for screen readers by ... charmeck-accordion-panel-group panel-group" role="tablist" aria-.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found