-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: Fix issue where saving throws an error after entering a decimal … #7997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { App, Directive } from 'vue'; | ||
| import integerInput from './modules/integer'; | ||
|
|
||
| const directivesList: { [key: string]: Directive } = { | ||
| 'integer-input': integerInput, | ||
| }; | ||
|
|
||
| const directives = { | ||
| install: function (app: App<Element>) { | ||
| Object.keys(directivesList).forEach((key) => { | ||
| app.directive(key, directivesList[key]); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export default directives; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type { Directive, DirectiveBinding } from 'vue'; | ||
|
|
||
| const integerInput: Directive = { | ||
| mounted(el: HTMLElement, binding: DirectiveBinding) { | ||
| const { value } = binding; | ||
| el.addEventListener('input', (event: Event) => { | ||
| const inputElement = event.target as HTMLInputElement; | ||
| let inputValue = inputElement.value; | ||
| inputValue = inputValue.replace(/\..*/, ''); | ||
| if (value?.min !== undefined && Number(inputValue) < value.min) { | ||
| inputValue = value.min.toString(); | ||
| } | ||
| if (value?.max !== undefined && Number(inputValue) > value.max) { | ||
| inputValue = value.max.toString(); | ||
| } | ||
| inputElement.value = inputValue; | ||
| const inputEvent = new Event('input', { bubbles: true }); | ||
| inputElement.dispatchEvent(inputEvent); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export default integerInput; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no known irregularities or potential issues with the code provided. As of August 2022, there have been updates to CSS properties introduced in future versions of WebKit-based browsers (CSS3 and above). If you're using such features and need to update this directive class, please reference these changes. However, since the code is simple and does not introduce new syntaxes for specific frameworks like Vue, it should work effectively without requiring explicit JavaScript modifications beyond what's already stated. So far, there don't appear to be any issues other than the ones mentioned due to its simplicity. If there were bugs affecting modern browsers where I would suggest keeping this updated only as needed based on new browser compatibility needs. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ import hljsVuePlugin from '@highlightjs/vue-plugin'; | |
| import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'; | ||
| import VirtualScroller from 'vue-virtual-scroller'; | ||
|
|
||
| import directives from '@/directives/index'; | ||
|
|
||
| const app = createApp(App); | ||
| app.use(hljsVuePlugin); | ||
| app.component('SvgIcon', SvgIcon); | ||
|
|
@@ -43,4 +45,6 @@ app.use(router); | |
| app.use(i18n); | ||
| app.use(pinia); | ||
| app.use(Components); | ||
| app.use(directives); | ||
|
|
||
| app.mount('#app'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None found |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not find any major syntax errors in your provided code. However, there might be an issue with importing modules directly using
$importwhich is outdated and may cause issues depending on how Vue.js was configured or updated since 2017.Here's a minor improvement suggestion: