@@ -13,6 +13,7 @@ import Select from "../../src/Select.js";
1313import Option from "../../src/Option.js" ;
1414import CheckBox from "../../src/CheckBox.js" ;
1515import Bar from "../../src/Bar.js" ;
16+ import Link from "../../src/Link.js" ;
1617
1718function getGrowingWithScrollList ( length : number , height : string = "100px" ) {
1819 return (
@@ -729,6 +730,98 @@ describe("List Tests", () => {
729730 cy . get ( "@itemClickStub" ) . should ( "not.have.been.called" ) ;
730731 } ) ;
731732
733+ it ( "fires item-click when nested ui5-link is clicked" , ( ) => {
734+ cy . mount (
735+ < List >
736+ < ListItemCustom >
737+ < div >
738+ < span > First List Item</ span >
739+ < Link id = "nested-link" href = "#" > Details</ Link >
740+ </ div >
741+ </ ListItemCustom >
742+ </ List >
743+ ) ;
744+
745+ cy . get ( "[ui5-list]" ) . then ( ( $list ) => {
746+ $list [ 0 ] . addEventListener ( "ui5-item-click" , cy . stub ( ) . as ( "itemClickStub" ) ) ;
747+ } ) ;
748+
749+ cy . get ( "#nested-link" ) . then ( ( $link ) => {
750+ const linkClickStub = cy . stub ( ) . as ( "linkClickStub" ) ;
751+ $link [ 0 ] . addEventListener ( "click" , linkClickStub ) ;
752+ } ) ;
753+
754+ cy . get ( "#nested-link" ) . click ( ) ;
755+
756+ cy . get ( "@linkClickStub" ) . should ( "have.been.calledOnce" ) ;
757+ cy . get ( "@itemClickStub" ) . should ( "have.been.calledOnce" ) ;
758+ } ) ;
759+
760+ it ( "does not fire item-click when nested disabled custom element is clicked" , ( ) => {
761+ cy . mount (
762+ < List >
763+ < ListItemCustom >
764+ < div >
765+ < span > First List Item</ span >
766+ < div id = "custom-host" > </ div >
767+ </ div >
768+ </ ListItemCustom >
769+ </ List >
770+ ) ;
771+
772+ cy . get ( "[ui5-list]" ) . then ( ( $list ) => {
773+ $list [ 0 ] . addEventListener ( "ui5-item-click" , cy . stub ( ) . as ( "itemClickStub" ) ) ;
774+ } ) ;
775+
776+ cy . get ( "#custom-host" ) . then ( ( $host ) => {
777+ const customAction = document . createElement ( "x-action" ) ;
778+ customAction . id = "disabled-custom-action" ;
779+ customAction . setAttribute ( "aria-disabled" , "true" ) ;
780+ customAction . textContent = "Disabled Action" ;
781+ $host [ 0 ] . appendChild ( customAction ) ;
782+
783+ const customClickStub = cy . stub ( ) . as ( "customClickStub" ) ;
784+ customAction . addEventListener ( "click" , customClickStub ) ;
785+ } ) ;
786+
787+ cy . get ( "#disabled-custom-action" ) . click ( ) ;
788+
789+ cy . get ( "@customClickStub" ) . should ( "have.been.calledOnce" ) ;
790+ cy . get ( "@itemClickStub" ) . should ( "not.have.been.called" ) ;
791+ } ) ;
792+
793+ it ( "fires item-click when nested custom element is not disabled" , ( ) => {
794+ cy . mount (
795+ < List >
796+ < ListItemCustom >
797+ < div >
798+ < span > First List Item</ span >
799+ < div id = "custom-host-enabled" > </ div >
800+ </ div >
801+ </ ListItemCustom >
802+ </ List >
803+ ) ;
804+
805+ cy . get ( "[ui5-list]" ) . then ( ( $list ) => {
806+ $list [ 0 ] . addEventListener ( "ui5-item-click" , cy . stub ( ) . as ( "itemClickStub" ) ) ;
807+ } ) ;
808+
809+ cy . get ( "#custom-host-enabled" ) . then ( ( $host ) => {
810+ const customAction = document . createElement ( "x-action" ) ;
811+ customAction . id = "enabled-custom-action" ;
812+ customAction . textContent = "Enabled Action" ;
813+ $host [ 0 ] . appendChild ( customAction ) ;
814+
815+ const customClickStub = cy . stub ( ) . as ( "customClickStub" ) ;
816+ customAction . addEventListener ( "click" , customClickStub ) ;
817+ } ) ;
818+
819+ cy . get ( "#enabled-custom-action" ) . click ( ) ;
820+
821+ cy . get ( "@customClickStub" ) . should ( "have.been.calledOnce" ) ;
822+ cy . get ( "@itemClickStub" ) . should ( "have.been.calledOnce" ) ;
823+ } ) ;
824+
732825 it ( "selectionChange events provides previousSelection item" , ( ) => {
733826 cy . mount (
734827 < div >
0 commit comments