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.

[antd] Losing focus on first entered character when I use a custom FieldTemplate or ObjectFieldTemplate

See original GitHub issue

Prerequisites

Description

I am trying to use a fieldtemplate to change the layout of each field of the form. When I add my field template to the parameters of the form and use setState in componentDidMount , and I try to use any input, I lose the focus almost instantly. It is a behaviour I am not having without the fieldtemplate or objectFieldTemplate.

Steps to Reproduce

  1. [enter a character]

Expected behavior

I can enter any character.

Actual behavior

focus is lost

Demo

https://github.com/NaccOll/rjsf-custom-fieldtemplate

Version

You can usually get this information in your package.json or in the file URL if you’re using the unpkg one.

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@ant-design/icons": "^4.2.2",
    "@rjsf/antd": "^2.4.0",
    "@rjsf/core": "^2.4.0",
    "@testing-library/jest-dom": "^5.11.5",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "antd": "^4.7.3",
    "dayjs": "^1.9.4",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.0",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15

github_iconTop GitHub Comments

8reactions
cejaramillofcommented, Nov 27, 2020

@jaramillo-carlos I tested your ObjectFieldTemplate and it seems to be working, something else might be affecting your form

You test having state inside a useState? im having problems with i use both, onChange with state, and my ObjectFieldTemplate 😦

Was fixed, extracting the function ObjectFieldTemplate out of the component.

1reaction
yuvalshi0commented, Nov 1, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - react-jsonschema-form input box out of focus when ...
The problem is that I'm using ObjectFieldTemplate and every time I enter a character in one of the string input boxes, the box...
Read more >
Advanced customization - React Jsonschema form
To fully customize an object field template, you may need to specify both ui:FieldTemplate and ui:ObjectFieldTemplate . Error List template¶. To take control ......
Read more >
Input - Ant Design
A basic widget for getting the user input is a text field. Keyboard and mouse can be used for providing or changing data....
Read more >
User Manual for Kingdee K/3 V12.1 BOS Plug-in Development
This manual is intended for users who have extensive related experience and expertise, and who are already familiar with the basics of the ......
Read more >
Set Up and Maintain Sales Tools - manualzz
Customize Application and Modify All Data. 2. If it's your first time visiting the Sales Cloud Einstein Setup Assistant, click Get Started.
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