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(VDialog/VMenu): enable pointer-events for disabled activator #5511

Merged
merged 3 commits into from
Dec 14, 2018

Conversation

jacekkarczmarczyk
Copy link
Member

@jacekkarczmarczyk jacekkarczmarczyk commented Nov 2, 2018

Description

Don't render contents and remove pointer-events: none for disabled menu/dialog

Motivation and Context

fixes #5472

How Has This Been Tested?

visuall, updated unit

Markup:

<template>
  <v-app>
    <v-content>
      <v-checkbox label="Disabled" v-model="disabled"></v-checkbox>
      <v-menu :disabled="disabled">
        <v-btn slot="activator">Menu</v-btn>
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-menu :disabled="disabled" open-on-hover>
        <v-btn slot="activator">Menu (hover)</v-btn>
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-btn id="external-disabled">External activator</v-btn>
      <v-menu :activator="activators['external-disabled']" :disabled="disabled">
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-btn id="external-disabled-hover">External activator (hover)</v-btn>
      <v-menu open-on-hover :activator="activators['external-disabled-hover']" :disabled="disabled">
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-dialog :disabled="disabled">
        <v-btn slot="activator">Dialog</v-btn>
        <v-card><v-card-text>I'm dialog</v-card-text></v-card>
      </v-dialog>
      <v-bottom-sheet :disabled="disabled">
        <v-btn slot="activator">Bottom sheet</v-btn>
        <v-card><v-card-text>I'm bottom sheet</v-card-text></v-card>
      </v-bottom-sheet>
      <v-subheader>Active</v-subheader>
      <v-menu>
        <v-btn slot="activator">Menu</v-btn>
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-menu open-on-hover>
        <v-btn slot="activator">Menu (hover)</v-btn>
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-btn id="external-enabled">External activator</v-btn>
      <v-menu :activator="activators['external-enabled']">
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-btn id="external-enabled-hover">External activator (hover)</v-btn>
      <v-menu open-on-hover :activator="activators['external-enabled-hover']">
        <v-card><v-card-text>I'm menu</v-card-text></v-card>
      </v-menu>
      <v-dialog>
        <v-btn slot="activator">Dialog</v-btn>
        <v-card><v-card-text>I'm dialog</v-card-text></v-card>
      </v-dialog>
      <v-bottom-sheet>
        <v-btn slot="activator">Bottom sheet</v-btn>
        <v-card><v-card-text>I'm bottom sheet</v-card-text></v-card>
      </v-bottom-sheet>
    </v-content>
  </v-app>
</template>

<script>
export default {
  data: () => ({
    activators: {},
    disabled: true
  }),
  mounted () {
    ['external-disabled', 'external-disabled-hover', 'external-enabled', 'external-enabled-hover'].forEach(id => {
      this.$set(this.activators, id, document.getElementById(id))
    })
  }
}
</script>

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 feature but make 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 breaking 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)

@jacekkarczmarczyk jacekkarczmarczyk added the pending team review The issue is pending a full team review label Nov 2, 2018
@codecov
Copy link

codecov bot commented Nov 2, 2018

Codecov Report

Merging #5511 into dev will decrease coverage by 0.05%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #5511      +/-   ##
==========================================
- Coverage   88.58%   88.53%   -0.06%     
==========================================
  Files         281      281              
  Lines        6169     6173       +4     
  Branches     1534     1535       +1     
==========================================
  Hits         5465     5465              
- Misses        587      589       +2     
- Partials      117      119       +2
Impacted Files Coverage Δ
packages/vuetify/src/components/VMenu/VMenu.js 83.63% <0%> (-6.56%) ⬇️
packages/vuetify/src/components/VDialog/VDialog.js 72.72% <100%> (ø) ⬆️
...tify/src/components/VMenu/mixins/menu-activator.js 46.15% <100%> (-2%) ⬇️
...ify/src/components/VMenu/mixins/menu-generators.js 84.61% <66.66%> (+0.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 386d89f...e19fa91. Read the comment docs.

Copy link
Member

@johnleider johnleider left a comment

Choose a reason for hiding this comment

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

I wonder if this type of logic should be in bootable so we don't have to duplicate the logic.

}, children)
}, [
this.genActivator(),
this.disabled ? null : this.genContent()
Copy link
Member

Choose a reason for hiding this comment

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

Could this be handled in genContent similar to what genActivator does?

@@ -145,6 +145,77 @@ export default {
// Since this should only be called in a capture event (bottom up), we shouldn't need to stop propagation
return getZIndex(this.$refs.content) >= this.getMaxZIndex()
},
genActivator () {
if (!this.$slots.activator) return null
if (this.disabled) return this.$slots.activator
Copy link
Member

@KaelWD KaelWD Nov 18, 2018

Choose a reason for hiding this comment

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

This will cause different layout behaviour depending on if the dialog is disabled or not. Didn't we say to just ignore the click event? It doesn't need a rewrite of the entire render function.

@jacekkarczmarczyk jacekkarczmarczyk force-pushed the fix/#5472-enable-pointer-events-for-disabled-menu branch from a75380c to 7fd37bf Compare November 19, 2018 09:28
@jacekkarczmarczyk jacekkarczmarczyk added this to the v1.4.0 milestone Nov 26, 2018
@johnleider johnleider added the T: bug Functionality that does not work as intended/expected label Dec 2, 2018
@johnleider
Copy link
Member

Please create unit tests that correlate to the changes made in this request.

johnleider
johnleider previously approved these changes Dec 9, 2018
@jacekkarczmarczyk jacekkarczmarczyk force-pushed the fix/#5472-enable-pointer-events-for-disabled-menu branch from ea0b9ae to e19fa91 Compare December 11, 2018 03:43
@jacekkarczmarczyk
Copy link
Member Author

Update: added tests and external activator support, updated Playground.vue. The button for menu with external activator and open-on-hover prop doesn't work though because of #5860

@lock
Copy link

lock bot commented Apr 14, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please direct any non-bug questions to our Discord

@lock lock bot locked as resolved and limited conversation to collaborators Apr 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants