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

bug: dotobject should return null when a key is not found #242

Closed
elboletaire opened this issue Aug 17, 2023 · 0 comments
Closed

bug: dotobject should return null when a key is not found #242

elboletaire opened this issue Aug 17, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@elboletaire
Copy link
Member

elboletaire commented Aug 17, 2023

Describe the bug

Current dotobject behavior is to return the most nearest parent found, whilst it should be returning null (or undefined) when not finding a key

To Reproduce

Use election.get('token.type') in an election not having token.type defined. If it has token it will return token's contents; when not having even the token field defined, it returns the parent meta one.

Expected behavior

To have a falsy return when the key does not exist.

Workaround

Right now, to workaround this, I'm checking the type of the response whenever possible, i.e.

{typeof election?.get('token.type') === 'string' && (
  <Box>
    <Text color='process.date' fontWeight='bold'>
      {t('process.token_type')}
    </Text>
    <Text textTransform='capitalize'>{election.get('token.type')}</Text>
  </Box>
)}

Otherwise in cases like this it would fail, since objects cannot be directly render as JSX elements.

Additional context

I'll try to fix it myself, since it was implemented by me (unless someone wants to dig in it first, ofc).

@elboletaire elboletaire added the bug Something isn't working label Aug 17, 2023
@elboletaire elboletaire self-assigned this Aug 17, 2023
marcvelmer added a commit that referenced this issue Aug 29, 2023
marcvelmer added a commit that referenced this issue Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant