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

bug: setting button="true" after load does not make item focusable #28525

Closed
3 tasks done
eLyrin opened this issue Nov 14, 2023 · 1 comment · Fixed by BenOsodrac/ionic-framework#1 or #28892
Closed
3 tasks done
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@eLyrin
Copy link

eLyrin commented Nov 14, 2023

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

when navigated via tab-key, the ion-item is not highlighted correctly after switching from button=false to button=true.

Expected Behavior

ion-item should adjust it's highlighting styles when the button property changes.
the css classes ion-focusable and ion-focused are no longer present when the bug appears.

my wild guess is that this.focusable is initialized once, but never updated:
https://github.com/ionic-team/ionic-framework/blob/v7.5.0/core/src/components/item/item.tsx#L265

Steps to Reproduce

It's important to start with foo = false as initial value to reproduce the bug.

<ion-button (click)="foo = !foo">toggle</ion-button>
<ion-item [button]="foo">
  <ion-text>button mode active: {{foo}}</ion-text>
</ion-item>

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 7.1.1
Ionic Framework : @ionic/angular 7.5.0
@angular-devkit/build-angular : 16.2.10
@angular-devkit/schematics : 16.2.1
@angular/cli : 16.2.1
@ionic/angular-toolkit : 9.0.0

Capacitor:

Capacitor CLI : 4.8.1
@capacitor/android : 4.8.1
@capacitor/core : 4.8.1
@capacitor/ios : 4.8.1

Cordova:

Cordova CLI : not installed
Cordova Platforms : not available
Cordova Plugins : not available

Utility:

cordova-res : not installed globally
native-run : 1.7.4

System:

NodeJS : v18.18.2 (C:\Program Files\nodejs\node.exe)
npm : 9.8.1
OS : Windows 10

@ionitron-bot ionitron-bot bot added the triage label Nov 14, 2023
@liamdebeasi liamdebeasi changed the title bug: ion-item not being updated bug: setting button="true" after load does not make item focusable Nov 14, 2023
@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Nov 14, 2023
@ionitron-bot ionitron-bot bot removed the triage label Nov 14, 2023
github-merge-queue bot pushed a commit that referenced this issue Jan 26, 2024
Issue number: resolves #28525

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
When navigated via tab-key, the ion-item is not highlighted correctly
after switching from button=false to button=true.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->
Now, when dynamically changing the the `button` option to `True`,
there's a `@watch` callback that will make sure the internal
`isFocusable` `@state` will be updated.

- A new unit test was added to item/test. As there was still any unit
test for the `ion-item`, a new files was created - `item.spec.tsx`

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

New behavior in runtime:


![focusable](https://github.com/BenOsodrac/ionic-framework/assets/32780808/5c2179cb-c121-4529-92cc-4fb3d764b027)

---------

Co-authored-by: Sean Perkins <sean@ionic.io>
Copy link

ionitron-bot bot commented Feb 25, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
2 participants