Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/number_format_base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ export default function NumberFormatBase<BaseType = InputAttributes>(

useIsomorphicLayoutEffect(() => {
const input = focusedElm.current;
if (formattedValue !== lastUpdatedValue.current.formattedValue && input) {
const activeElement = document.activeElement;

if (input === activeElement && formattedValue !== lastUpdatedValue.current.formattedValue && input) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm, @kasperdun can you share an example where this is breaking? Basically focusedElm.current is set only when that input is focused. As we set the focusedElm.current to undefined when a blur is called.

const caretPos = getNewCaretPosition(
lastUpdatedValue.current.formattedValue,
formattedValue,
Expand Down