-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added back button for nav bar #141
Added back button for nav bar #141
Conversation
A different solution would be to add a custom Element, don't know what would be preferred? Example:
|
I personally prefer this because it means you're still enforcing that all buttons should have some sort of ID, unlike if you allow nil as the id (which I hope helps with accessibility in the app because people will have to assign an accessibility label or identifier) |
Don't most back buttons have a specific title or label? Either "Back" or the title of the previous screen? This could maybe be solved with an extension or update on NavBar: extension NavBar {
func backButton(titled title: String = "Back") -> Button {
return Button(id: title, parent: self)
}
} |
By default the back item has the title of the previous screen, would be nice to make it more foolproof
|
Yeah that's what I said 😬 in your tests you'd have to know what the previous screen was so you can tap the back button, but since you're in control of your tests that shouldn't be a problem? Given(I: tap(navBar.backButton(titled: "sdgsdfgdf"))) |
I have to check in our real project, because we are doing some magic to hide the title in the navigationbar.
|
You could just remove the default, it was there as a suggestion :) I'm guessing the title is "" because you've removed the title and just have an arrow? What happens for VoiceOver when it navigates over that, I assume it just reads out "Back"? It might be worth putting a breakpoint in your tests when the button is visible and then printing out the hierarchy so you can see what the tests can see:
Alternatively you might be able to just use the Accessibility Inspector. As a last resort you could add a custom accessibilityIdentifier to the back button wherever you're removing the title? |
Yeah there you go, "Vorige" is Dutch for "Previous"
|
Cool so in your tests you could just use |
This reverts commit e0ad7e9.
Sounds like a plan! I just reverted my previous commit & processed your feedback :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Could you add some tests as well and update the changelog + readme?
@@ -14,6 +14,5 @@ struct TableSelectionScreen: Screen { | |||
|
|||
let trait = View(id: "TableSelection") | |||
let navBar = NavBar() | |||
let backButton = Button(id: "Table") | |||
|
|||
let backButton = NavBar().backButton(titled: "Table") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be navBar.backButton
instead?
let backButton = NavBar().backButton(titled: "Table") | |
let backButton = navBar.backButton(titled: "Table") |
What's in this PR?
Replace this text with information about what's in your PR. What's changed? Why has it changed? Reference any GitHub issue this PR relates to, etc.
Pre-merge checklist
Before merging any PR, please check the following common things that should be done beforehand. These aren't all always required, so just check the box if it doesn't apply.
TABTestKit
target, notPods-TABTestKit_Example
etc.pod install
to ensure that the latest changes are in the Example project. Without this, Carthage might not see the latest changes.CHANGELOG
. For any changes pending a release, add to the Pending section. For releases, move everything pending to the release section.README
. Add info for any new features, update existing info for anything that's changed or needs extra info.