Open uncvrd opened 3 years ago
Could you provide #
to the href and have it fit your use case?
I don't think we would want to make the href optional as that would be really confusing.
@elylucas thanks for this suggestion! Two things:
#
is a great idea, however, it would appear that IonTabButton
overrides the onClick
event? I did this:<IonTabButton
tab="create"
href="#"
onClick={() => {
console.log('test');
}}
>
<IonIcon icon={addCircle} />
<IonLabel>Create</IonLabel>
</IonTabButton>
However, I do not see test
in my console after clicking on the element, therefore I don't think I can trigger a modal from the onClick
.
IonTabButton
, href
is already optional. Does this typing need to be updated to prevent someone running in to this issue?EDIT: so yea it looks like the onClick
is overridden on <Host>
to call selectTab
and then e.preventDefault()
is called which prevents event bubbling (I think). https://github.com/ionic-team/ionic-framework/blob/c1455a839a25e3e23b7c9e7b7d930055b24c2ecb/core/src/components/tab-button/tab-button.tsx#L96
Bug Report
Ionic version:
[x] 5.0.7
Current behavior:
I am using an IonTabs project. In my tab bar at the bottom, I have a "Create" button that I would like to have trigger a modal on the screen. However, when I click the tab, I receive a routing error because I am not including the
href
property in theIonTabButton
. Thehref
property isn't marked as required, so I figured I could remove thehref
property since I don't want to be routed to a different page. Instead I'd like to call theonClick
event to trigger the modal on the screen.Obviously, it's trying to find the value of the
href
and errors on thesplit
.Repo to replicate: https://github.com/uncvrd/tabs-as-buttons (I only modified the App.tsx)
Steps to recreate:
I would like to be able to use the
IonTabButton
as a normal button if thehref
is not added as a property.Stack trace here:
Ionic info: