-
Notifications
You must be signed in to change notification settings - Fork 93
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
Fix inverted validate label check in NcInputField #3980
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e5cfa8a
Fix inverted validate label check in NcInputField
raimund-schluessler 1d87924
Validate NcInputField label on component creation
raimund-schluessler 2418028
Use warn to indicate missing label prop
raimund-schluessler 842639f
Use computed to check for valid label
raimund-schluessler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Warn in computed = log every time the computed changes. It might not be the desired outcome
I'm not sure this is a good idea 🤔
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.
Wouldn't the same happen if we warn in the watcher? The computed changes, the watcher fires, checks the label and warns in case it is not valid!?
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.
Hum, good point 🙈
I'm weirded out by this anti pattern though 😁
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.
Are we sure the computed is not executed on other occasions? if so, you can merge !
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.
The computed is triggered every time
label
orlabelOutside
is changed, but of cause the warning will only be fired if one of both is falsy.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.
@skjnldsv I don't know whether it's an anti-pattern, but we do the same here for example: https://github.com/nextcloud/nextcloud-vue/blob/master/src/mixins/actionText.js#L87-L93 🙈
I would think so too. If
label
changes betweenFalse
,undefined
,null
, an empty string or anything else evaluating toFalse
, the warning would be triggered again even though it was invalid before already. But that seems a bit theoretic to me.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.
Let's hear what @ShGKme thinks about this approach 🙂
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.
looks at blame
sees @skjnldsv
closes tab
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.
It's too late, but yes 😅.
It proper works, but it is an anti-pattern,
computed
should never have side-effects, only computing the value.In options API there is a place for
computed + watch
, in Composition -watchEffect
.