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.

placeholder prop reused incorrectly when rerendering text input with cloneElement wrapper - MS Edge only

See original GitHub issue

Discovered this while creating some form dialog boxes using preact-portal. See reproduction here: https://jsfiddle.net/billneff79/bcphq0zr/

I believe this represents the minimum amount needed to reproduce the issue, which includes:

  1. A text input with a placeholder attribute and no value
  2. A component that wraps the input and uses cloneElement to render its child, the text input
  3. render the wrapped text input with placeholder text “foo” -> render null in place of the wrapped element -> render the wrapped text input with placeholder text “bar”

Only occurs in Edge (tested using Microsoft Edge 40.15063.674.0)

Expected Outcome text input with placeholder text of “bar”

Actual Outcome in Edge text input with placeholder text of “foo”

screenshot

Other Notes I created a similar setup using React and did not encounter the same problem on Edge: https://jsfiddle.net/billneff79/6b2eu3wy/4/

The cloneElement with a wrapping parent seems important. If there is no wrapping element, (e.g. if you just clone inline) the issue does not occur.

I have not seen this issue on any other browsers.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mcihakcommented, Sep 13, 2018

We have encountered this issue in our project and fixed it by workaround mentioned in https://github.com/developit/preact/issues/1208 (we disabled Preact component recycling for the component which wraps input element).

0reactions
marvinhagemeistercommented, Mar 5, 2019

Good news: We completely removed the recycler from Preact. Bugs like this where the wrong components are reused are now a thing of the past 👍 An alpha is already available on npm and a final version should follow sometime soon 💯

Read more comments on GitHub >

github_iconTop Results From Across the Web

placeholder prop reused incorrectly when rerendering text ...
A text input with a placeholder attribute and no value; A component that wraps the input and uses cloneElement to render its child,...
Read more >
How to avoid re rendering text input? - Stack Overflow
justi wrap the component in React.memo() . const component = React.memo((props) => {return ()}) and useMemo is used for ...
Read more >
react-addons-clone-with-props | Yarn - Package Manager
This solves an issue that already exists in React 17 and below, but it's even more important in React 18 because of how...
Read more >
material-ui/core/CHANGELOG.md - UNPKG
`event.preventDefault()` is meant to stop default behaviors like clicking a checkbox to check it, hitting a button to submit a form, and hitting...
Read more >
mbacc - Seaside Resort
Seaside Resort is located only 2.5 miles north of all the shopping and dining adventures Barefoot Landing has to offer. Choose from spacious...
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