Skip to content

Fix CurrencyInputProps leaking into underlying <input> element via customProps spread - #49

Merged
ericblade merged 3 commits into
masterfrom
copilot/fix-logvalues-parameter-handling
Sep 28, 2026
Merged

ericblade merged 3 commits into
masterfrom
copilot/fix-logvalues-parameter-handling

Conversation

Copilot AI commented Sep 28, 2026 •

Copy link
Copy Markdown

prepareProps didn't destructure all CurrencyInputProps fields before the ...customProps rest spread, causing props like logValues, onBlur, onClick, onFocus, style, id, and tabIndex to be forwarded as raw HTML attributes on the <input> element.

Changes

  • prepareProps destructuring — Added the missing CurrencyInputProps fields to the destructuring so they are stripped from customProps before it is spread onto <input>:
    • logValues — primary reported culprit
    • onBlur, onClick, onFocus — already wired up explicitly in render/handlers, but were also leaking through customProps, causing duplicate/conflicting event handler bindings
    • style, id, tabIndex — same pattern; already set explicitly in render

After this change, customProps only contains genuinely "extra" HTML attributes consumers intend for the underlying <input> (e.g. data-*, aria-*, name, placeholder).

const {
    onChangeEvent,
    onBlur, onClick, onFocus,   // ← now stripped
    value: propValue,
    // ... existing fields ...
    style, id, tabIndex,        // ← now stripped
    logValues,                  // ← now stripped
    ...customProps              // only unknown HTML attrs remain
} = props;

@rollingversions

Copy link
Copy Markdown

There is no change log for this pull request yet.

Create a changelog

… input element

Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix logValues and prepareProps for input parameters Fix CurrencyInputProps leaking into underlying <input> element via customProps spread Sep 28, 2026
Copilot AI requested a review from ericblade September 28, 2026 00:42
@ericblade

Copy link
Copy Markdown
Owner

@copilot is there some way we can take advantage of typescript to make it so that anything added to CurrencyInputProps but not handled in prepareProps() will throw an error or warning?

…handled in prepareProps

Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>

Copilot AI commented Sep 28, 2026

Copy link
Copy Markdown
Author

@copilot is there some way we can take advantage of typescript to make it so that anything added to CurrencyInputProps but not handled in prepareProps() will throw an error or warning?

Yes — added an exhaustive check using TypeScript's type system in prepareProps (commit above). After all the known props are destructured, there's now:

const _: Record<keyof Required<CurrencyInputProps>, unknown> = {
    onBlur, onClick, onFocus, onChangeEvent,
    allowEmpty, allowNegative, autoFocus,
    disableSelectionHandling: propDisableSelectionHandling, selectAllOnFocus,
    decimalSeparator, inputType, precision, prefix, style, suffix, thousandSeparator,
    id, tabIndex, value: propValue,
    logValues,
};
void _;

Record<keyof Required<CurrencyInputProps>, unknown> requires every key in CurrencyInputProps to appear in the object literal. If anyone adds a new field to CurrencyInputProps but doesn't destructure it above (and add it here), TypeScript will error: Property 'newField' is missing in type '...' but required in type 'Record<keyof CurrencyInputProps, unknown>'.

@ericblade
ericblade marked this pull request as ready for review September 28, 2026 02:53
Copilot AI lite review requested due to automatic review settings September 28, 2026 02:53
@ericblade
ericblade merged commit 18904db into master Sep 28, 2026
1 of 2 checks passed
@ericblade
ericblade deleted the copilot/fix-logvalues-parameter-handling branch September 28, 2026 02:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The changes directly address the prop-leakage issue by removing known component props from customProps and add a compile-time guard to prevent regressions.

Review effort: Lite
Findings: None

What changed in this PR

This PR prevents CurrencyInputProps-specific fields from being forwarded to the underlying <input> via the customProps rest spread, addressing the reported logValues leak (and related prop leakage concerns) from issue #48.

Changes:

  • Updated prepareProps destructuring to explicitly pull out additional known CurrencyInputProps fields (onBlur, onClick, onFocus, style, id, tabIndex, logValues) so they don’t end up in customProps.
  • Added a TypeScript “exhaustiveness” check intended to fail compilation if CurrencyInputProps gains a new key that isn’t accounted for in prepareProps.
File Description
src/​index.tsx Ensures CurrencyInputProps fields don’t leak into <input> attributes via customProps, and adds a TS exhaustiveness guard.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logValues and perhaps other parameters are passed down into the <input> tag

3 participants