Skip to content
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(VSlider): add missing prepend and append icon click events #16079

Merged

Conversation

vexleet
Copy link
Contributor

@vexleet vexleet commented Nov 12, 2022

Description

Motivation and Context

There were props for adding click events for the append and prepend icons in the v slider but they weren't used in the component which led to not being able to have events for the icons, which would fix #16071

How Has This Been Tested?

I created a unit test using cypress which adds a slider with 2 icons and putting events on them, after that I used cypress spies to check if the button events worked when both icons were clicked.

Markup:

// Paste your FULL Playground.vue here

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • The PR title is no longer than 64 characters.
  • The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and backwards compatible changes and next for non-backwards compatible changes).
  • My code follows the code style of this project.
  • I've added relevant changes to the documentation (applies to new features and breaking changes in core library)

There were props for adding click events for the append and prepend icons in the v slider but they
weren't used in the component which led to not being able to have events for the icons. I also added
unit tests that check if the icons are clicked and if they have emitted an event.

fix vuetifyjs#16071
@johnleider johnleider requested a review from nekosaur November 14, 2022 21:18
@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VSlider VSlider labels Nov 14, 2022
@johnleider johnleider added this to the v3.0.x milestone Nov 14, 2022
Ran lint:fix in order to fix linting problems that the CI was having
@nekosaur
Copy link
Member

@KaelWD we're filtering out event props here

const keys = Object.keys(VInput.props).filter(k => !isOn(k))
which is the root cause of this issue. What's the reason we're doing this?

@KaelWD
Copy link
Member

KaelWD commented Dec 10, 2022

I think because VTextField does some other stuff first then waits a tick before re-emitting clear:

function onClear (e: MouseEvent) {
e.stopPropagation()
onFocus()
nextTick(() => {
model.value = null
callEvent(props['onClick:clear'], e)
})
}

If clear was part of fieldProps it'd happen twice
We could probably do something similar to line 145 though and just
const [{ 'onClick:clear': _, ...fieldProps }] = filterFieldProps(props)

@johnleider
Copy link
Member

Is that the advised direction @KaelWD? To add exceptions for those events?

@KaelWD KaelWD modified the milestones: v3.0.x, v3.1.x Jan 6, 2023
@johnleider
Copy link
Member

@KaelWD @nekosaur any updates?

@KaelWD KaelWD changed the base branch from next to master February 5, 2023 14:25
@johnleider
Copy link
Member

Possibly related: #15904, #16945, 133b417

@yuwu9145
Copy link
Member

yuwu9145 commented Apr 8, 2023

I think because VTextField does some other stuff first then waits a tick before re-emitting clear:

function onClear (e: MouseEvent) {
e.stopPropagation()
onFocus()
nextTick(() => {
model.value = null
callEvent(props['onClick:clear'], e)
})
}

If clear was part of fieldProps it'd happen twice
We could probably do something similar to line 145 though and just
const [{ 'onClick:clear': _, ...fieldProps }] = filterFieldProps(props)

VField is emitting "prependInner" rather than "prepend". So clear event shouldn't bother. Regarding this ticket, we should focus on filterInputProps for VInput as opposed to VField.

Removing .filter(k => !isOn(k)) on filterInputProps makes sense, it resolves all similar issues including #17070, however, would this be a breaking change?

I think it should be ok. Because VInput props only has two event emits: onClick:prepend & onClick:append:

  • Their event listeners does not seem to link to any nextTick effect like "clear" does in existing components
  • Even if in future, in case any of them has to be linked to any nextTick, we could just do something similar to that line 145 const [{ 'onClick:clear': _, ...fieldProps }] = filterFieldProps(props) (as @KaelWD suggested) in order to deliberately exclude an event from default filtered props and munally control its emit

@yuwu9145 yuwu9145 requested a review from KaelWD April 17, 2023 07:44
@johnleider johnleider changed the title fix(v-slider): added missing click events for prepend and append icons fix(VSlider): added missing click events for prepend and append icons Apr 17, 2023
@johnleider johnleider changed the title fix(VSlider): added missing click events for prepend and append icons fix(VSlider): add missing prepend and append icon click events Apr 17, 2023
@johnleider johnleider merged commit 586fc76 into vuetifyjs:master Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VSlider VSlider T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.0.1] v-slider append and prepend event is not working
5 participants