Code Monkey home page Code Monkey logo

update-input-width's People

Contributors

dependabot[bot] avatar wojtekmaj avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

update-input-width's Issues

[Request] Refactor to return computed width + separate function to update width on HTML element

Hello, first of all thanks for the library - we're using it in a React project, however we are facing issues with rendering due to the following line:

element.style.width = `${width}px`;

Updating the element like this makes the library not very React-friendly - DOM modifications should not be done on the element itself, but rather be relayed to the render method of each component.

A good addition to your lib would be splitting the logic inside updateInputWidth into a separate getUpdatedInputWidth and then allowing the consumer to set the width however they please (pass as props in the case of React).

Happy to do a PR if you think the request is reasonable.

TypeError: Cannot set property 'font' of null

Stacktrace:

at updateInputWidth (node_modules/update-input-width/dist/entry.js:22:16)
      at ref (node_modules/react-date-picker/dist/DateInput/Input.js:73:42)
      at commitAttachRef (node_modules/react-dom/cjs/react-dom.development.js:14456:7)
      at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:15467:7)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:100:14)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:138:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:187:29)
      at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:15603:7)
      at completeRoot (node_modules/react-dom/cjs/react-dom.development.js:16618:34)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:16563:9)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:16347:7)
      at scheduleWork$1 (node_modules/react-dom/cjs/react-dom.development.js:16218:11)
      at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:16785:3)
      at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:16812:10)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:16839:10)
      at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:17122:3)
      at node_modules/react-dom/cjs/react-dom.development.js:17262:14
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:16674:14)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:17258:5)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:17317:12)
      at node_modules/@testing-library/react/dist/index.js:86:25
      at Object.batchedUpdates$1 [as unstable_batchedUpdates] (node_modules/react-dom/cjs/react-dom.development.js:16659:12)
      at actPolyfill (node_modules/@testing-library/react/dist/act-compat.js:51:21)
      at render (node_modules/@testing-library/react/dist/index.js:82:26)
      at Object.<anonymous> (<RELEVANT_FILE_PATH>/tests/index.test.js:20:27)

Issue:
When running tests with the Jest framework the react-datetime-picker would break the tests with this error and stacktrace. Would not break during npm start, just broke during test.

Fix:
Dependencies:

    "react-datetime-picker": "2.4.0",

Resolutions:

"resolutions": {
    "react-datetime-picker/react-date-picker": "7.5.1",
    "react-datetime-picker/react-time-picker": "3.5.2"
  }

getFontShorthand returns " / " when element is not mounted in DOM tree

With 7.8.1, rendering a DatePicker in a react-responsive-modal fails. Rendering inside the same modal after a delay works.

The error happens in line 20 of Input.jsx wojtekmaj/react-date-picker@e0cc576 , and this might technically be a bug in getFontShorthand() from update-input-width.

It looks like this is because the modal's content is initially created outside of the document's DOM and document.getComputedStyle(element) doesn't contain any font styles.

If the modal appears first and then displays the form after a delay (e.g. ajax loading), rendering works.

https://codesandbox.io/s/brave-fermat-u3t45

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.