From e269cee11bb5e0cdc243a4b02e7d766b58228bd3 Mon Sep 17 00:00:00 2001 From: "kai.arrowood" Date: Wed, 4 May 2022 12:10:58 -0400 Subject: [PATCH] fix(ktable): fix row click handling --- docs/components/table.md | 105 ++++++++++++++++++++++++------- src/components/KTable/KTable.vue | 6 +- 2 files changed, 88 insertions(+), 23 deletions(-) diff --git a/docs/components/table.md b/docs/components/table.md index fdf868a1d1..d1d452d7b9 100644 --- a/docs/components/table.md +++ b/docs/components/table.md @@ -537,49 +537,58 @@ export default { ## Events -Bind any DOM [events](https://developer.mozilla.org/en-US/docs/Web/Events) to various parts of the table. We support events on both table rows and cells in addition to click elements inside a row (ie. buttons or hyperlinks) without triggering the a row or cell event. You can also add logic to check for `metakey` to support cmd/ctrl when clicking. Examples highlighted below. +Bind any DOM [events](https://developer.mozilla.org/en-US/docs/Web/Events) to various parts of the table. We support events on both table rows and cells, but must be careful with clickable content in rows when row click is enabled. You can also add logic to check for `metakey` to support cmd/ctrl when clicking. Examples highlighted below. ### Rows `@row:{event}` - returns the `Event`, the row item, and the type: `row` -```vue - -``` +To avoid firing row clicks by accident, the row click handler ignores events coming from `a`, `button`, `input`, and `select` elements (unless they have the `disabled` attribute). As such click handlers attached to these element types do not require stopping propagation via `@click.stop`. + -```vue +```html + + ``` -### Cells +Click events tied to non-ignored elements (not `a`, `button`, `input`, `select`) must use the `.stop` keyword to stop propagation firing the row click handler. -`@cell:{event}` - returns the `Event`, the cell value, and the type: `cell` +Using a `KPop` inside of a clickable row requires some special handling. Non-clickable content must be wrapped in a `div` with the `@click.stop` attribute to prevent the row click handler from firing if a user clicks content inside of the popover. Any handlers on non-ignored elements will need to have `.stop`. + + + + + + ```vue - + + + + + ``` +### Cells + +`@cell:{event}` - returns the `Event`, the cell value, and the type: `cell` +