Skip to content

Can't pass searchKey a dynamic value #1006

Description

@sharjeelyunus

Describe the bug
We can only pass string in searchKey, but need to pass dynamic value to make it reusable, i.e like this searchKey: ${searchKey}
if we pass it like this, searching working, but it doesn't select the value

getting value like this: value: "undefined_2"
Image

EDL:

Widget:
  inputs:
    - label
    - widgetId
    - placeholder
    - tenant
    - required
    - error
    - searchKey
  body:
    Column:
      styles:
        gap: ${spacing['2']}
      children:
        - Row:
            styles:
              gap: ${spacing['1']}
            children:
              - Text:
                  text: '*'
                  styles:
                    visible: ${!!required}
                    color: ${colors.red['500']}
                    fontSize: ${spacing['4']}
              - Text:
                  text: ${label}
                  styles:
                    fontWeight: ${typography.fontWeight.semibold}
        - Search:
            id: ${widgetId}
            label: Diagnosis Search
            styles:
              width: 100%
              borderRadius: ${spacing['2']}
              borderWidth: 2
              borderStyle: solid
              borderColor: ${colors.gray['200']}
              backgroundColor: ${colors.gray['50']}
            placeholder: ${placeholder}
            item-template:
              data: ${searchDiagnoses.body.data.searchDiagnoses}
              name: diagnosis
              template:
                Column:
                  children:
                    - Text:
                        styles:
                          fontWeight: ${typography.fontWeight.semibold}
                          whiteSpace: normal
                        text: ${diagnosis[searchKey]}
            searchKey: ${searchKey}
            onSearch:
              debounceMs: 400
              invokeApi:
                name: searchDiagnoses
                inputs:
                  value: ${search}
                  token: ${ensemble.user.accessToken}
                  tenant: ${tenant}

        - Text:
            text: ${error}
            styles:
              color: ${colors.red['500']}
              visible: ${!!error}
API:
  searchDiagnoses:
    uri: ${ensemble.env.SUPERGRAPH_URL}
    method: POST
    inputs:
      - value
      - token
      - tenant
    headers:
      authorization: Bearer ${token}
      x-atlas-tenant: ${tenant}
    body:
      variables:
        value: ${value}
      operationName: SearchDiagnoses
      query: |
        query SearchDiagnoses($value: String!) {
          searchDiagnoses(value: $value) {
            code
            description
          }
        }

Additional Context
had to create 2 same widgets, just different search key, this could've been a single widget, if we can get the right value
https://github.com/atlas-health/atlas-navigator-ui/pull/1886

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingp1High priority

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions