Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triggerSibling Issue #99

Closed
mujahidateeb opened this issue Jun 9, 2018 · 5 comments · May be fixed by #151
Closed

triggerSibling Issue #99

mujahidateeb opened this issue Jun 9, 2018 · 5 comments · May be fixed by #151

Comments

@mujahidateeb
Copy link

mujahidateeb commented Jun 9, 2018

Hi,
I'm getting below issue while using triggerSibling can you please help me to sort out this issue
issue

This is my sample code using

<Collapsible
  tabIndex={list.group_id}
  triggerSibling={
    <div>
      <span className="col-sm-3">{list.group_name}</span>
      <div id="buttons" className="col-sm-3 Collapsible__trigger-sibling">
        <button
          type="button"
          data-toggle="modal"
          data-target="#addRequirementModal"
          onClick={() => this.addRequirement(list.group_id)}
        >
          <MaterialIcon icon="add" size={14} />
        </button>
        <Link
          to={`/requirement/${list.group_id}`}
          id={list.group_id}
          style={{ color: 'white' }}
        >
          <MaterialIcon icon="visibility" size={14} />
        </Link>
        <button
          type="button"
          value={list.group_id}
          onClick={() => this.getGroupDetails(list.group_id)}
          data-toggle="modal"
          data-target="#editModal"
        >
          <MaterialIcon icon="edit" size={14} />
        </button>
        <button
          type="button"
          value={list.group_id}
          onClick={() => this.deleteGroup(list.group_id)}
        >
          <MaterialIcon icon="delete" size={14} />
        </button>
      </div>
    </div>
  }
  key={list.group_id}
/>
@karltaylor
Copy link
Collaborator

Ah I know what the issue is here, it's something to do with returning the sibling as a component. I'll take a look at it shortly for this fix.

@karltaylor
Copy link
Collaborator

karltaylor commented Jun 22, 2018

This could be fixed if we update to check what is passed the to the triggerSibling prop. @glennflanagan is this something you would want to add?

The fix here is to pass the triggerSibling a <Component /> or an arrow function:

triggerSibling={() => <div>Hello<div>}

so we could simply pass this as a warning in the console instead? @rsarai do you have any thoughts on this?

renderNonClickableTriggerElement() {
  if (this.props.triggerSibling && typeof this.props.triggerSibling === 'string') {
    return (
      <span className={`${this.props.classParentString}__trigger-sibling`}>{this.props.triggerSibling}</span>
    )
+  } else if (typeof this.props.triggerSibling === 'object') {
+    return this.props.triggerSibling
+  } else if (typeof this.props.triggerSibling === 'function') {
+    return <this.props.triggerSibling />
+  }
  return null;
}

@karltaylor
Copy link
Collaborator

@mujahidateeb please let me know if this has solved your problem, re-open if you're still having problems

@ReidBraswell
Copy link

I'm having the same issue as well. Doesn't look like the original issue creator ever responded. @karltaylor was the proposed fix ever implemented? It doesn't appear to have been. Thanks for your help!

@manchaary
Copy link

manchaary commented Sep 19, 2019

@karltaylor here is there error i see (version 2.6.0)

No overload matches this call.
  Overload 1 of 2, '(props: Readonly<CollapsibleProps>): Collapsible', gave the following error.
    Type '() => Element' is missing the following properties from type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>': type, props, key
  Overload 2 of 2, '(props: CollapsibleProps, context?: any): Collapsible', gave the following error.
    Type '() => Element' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>'.  TS2769

    126 | 
    127 |   return (
  > 128 |     <Collapsible tabIndex={0} trigger="Im trigger here" triggerSibling={() => <div>Hello</div>}>

lud-hu pushed a commit to lud-hu/react-collapsible that referenced this issue Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants