# RBI Tech

Technical blog posts on JavaScript, React, GraphQL and friends - Medium

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Maintaining Focus

DevFeed: [Maintaining Focus](<https://devfeed.tech/articles/maintaining-focus-19121.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/maintaining-focus-4d111697f79a?source=rss----904782439303---4>)

Author: Andy Weiss

Published: 2021-02-28T14:19:06Z

Content type: tutorial

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [Ionic](<https://devfeed.tech/topics/ionic.md>), [Forms](<https://devfeed.tech/topics/forms.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>)

Tags: [browsers](<https://devfeed.tech/tags/browsers.md>), [focus](<https://devfeed.tech/tags/focus.md>), [form](<https://devfeed.tech/tags/form.md>), [hybrid-app-development](<https://devfeed.tech/tags/hybrid-app-development.md>), [ionic](<https://devfeed.tech/tags/ionic.md>), [ios](<https://devfeed.tech/tags/ios.md>), [keyboard](<https://devfeed.tech/tags/keyboard.md>), [viewport](<https://devfeed.tech/tags/viewport.md>)

### AI overview

Mobile Safari shifts form content up when the soft keyboard opens, while a hybrid iOS web view may leave fields covered and lacks the keyboard's "Done" button. The excerpt says Android behaves more like the mobile browser, so an iOS fix should preserve Android behavior. It begins a Capacitor-based approach: set the iOS keyboard resize option to "none," then slide the viewport so the focused field stays visible. The excerpt ends before explaining that viewport adjustment, so it does not support further implementation details.

### Source excerpt

Keeping Form Elements Visible in Hybrid iOS Apps Today's mobile browsers provide a pretty great default user experience for forms. For a very simple example, visit the following url from any mobile browser: https://VisualViewport.andyweiss1982.repl.co. The user experience is great from mobile Safari. When you focus on an input field, the phone's soft keyboard animates up from the bottom of the screen. All of the content comes along for the ride, intelligently sliding up so you can see each input's value as you type. Close out the form and the viewport gracefully recedes from view. However, the same exact code can become far less elegant when consumed from a web view inside of a hybrid iOS app. Not so great inside of an iOS web view Not only do we lose the "Done" button that closes the keyboard without submitting the form; in many cases, the keyboard will pop up without displacing the form elements, covering them entirely and making the form appear completely useless! Well, It works in my web browser? 🤷♂ For reference, here is the full code for the original user experience as viewed from the mobile web: https://medium.com/media/7d7adf83c321357f9af250d2c90d1d4e/href To move this code inside of a web view, we can use Ionic's capacitor package to generate a bare-bones hybrid app that can be run in a simulator. Following the docs, you can create a new project, give it a name and assign it a directory, and then add the Android and iOS platforms. npx @capacitor/cli create? App name hybrid-forms-test ? App Package ID (in Java package format, no dashes) com.example.app ? Directory for new app hybrid-forms-test ? Which npm client would you like to use? yarnAdd platforms using "npx cap add":npx cap add android npx cap add ios For the purposes of this demo, you can just copy and paste the following code into www/index.html to generate a carbon copy of the original example into a boilerplate capacitor web view that can be run as either an iOS or Android application: https://me

## Idiomatic Alternatives to Enums in TypeScript

DevFeed: [Idiomatic Alternatives to Enums in TypeScript](<https://devfeed.tech/articles/idiomatic-alternatives-to-enums-in-typescript-19120.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/idiomatic-alternatives-to-enums-in-typescript-fa8e6518d113?source=rss----904782439303---4>)

Author: Andy Weiss

Published: 2021-01-31T19:19:11Z

Content type: article

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [enum](<https://devfeed.tech/topics/enum.md>), [TypeScript](<https://devfeed.tech/topics/typescript.md>), [Transpilers](<https://devfeed.tech/topics/transpilers.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>), [ECMAScript](<https://devfeed.tech/topics/ecmascript.md>)

Tags: [alternatives](<https://devfeed.tech/tags/alternatives.md>), [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [ecmascript](<https://devfeed.tech/tags/ecmascript.md>), [enum](<https://devfeed.tech/tags/enum.md>), [enums](<https://devfeed.tech/tags/enums.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

### AI overview

TypeScript enums are emitted as runtime code, which the article says conflicts with TypeScript's goals of erasable types and clean, idiomatic JavaScript. `const enum` declarations disappear during compilation, but default to integer values and still introduce syntax outside JavaScript standards. The article recommends unions of string literals for readable values: they retain type safety, compile cleanly, and allow TypeScript to recognize matching strings from API responses where enums may not. For opaque values or existing enum-heavy code, it describes converting an enum to a `const` object literal, deriving a union from its keys, replacing enum members with string literals, then defining the union directly. The supplied text presents this as a gradual migration path; it does not include the full code examples.

### Source excerpt

If you're making a list, type check it once? TypeScript is often referred to as a syntactical superset of JavaScript. In practice, this means its compiler can understand standard JS, as well as the type declarations and annotations that enable its error-detecting superpowers. For the most part, the additional syntax provided by TypeScript is stripped away during trans-compilation to JS. Indeed, its ability to gracefully disappear and produce JavaScript output that closely resembles the original code as authored is a major part of its appeal and is enshrined in the project's design goals (emphasis mine): Statically identify constructs that are likely to be errors. Provide a structuring mechanism for larger pieces of code. Impose no runtime overhead on emitted programs. Emit clean, idiomatic, recognizable JavaScript code. Produce a language that is composable and easy to reason about. Align with current and future ECMAScript proposals. Preserve runtime behavior of all JavaScript code. Avoid adding expression-level syntax. Use a consistent, fully erasable, structural type system. Be a cross-platform development tool. Do not cause substantial breaking changes from TypeScript 1.0. What, then, to make of TypeScript enums? 🤔 The idea of an enumerated type -- that a programmer can constrain the values a piece of data can hold to a pre-defined list, and be alerted when their actions diverge from their intentions -- has a rich tradition in programming going all the way back to C. Enums are native to TypeScript, but don't exist in JavaScript. But while enums are supported in TypeScript, there is no corresponding implementation in JavaScript. Worse yet, rather than disappear from the emitted JS output, they are trans-compiled into code that would be hard to refer to as clean or idiomatic. https://bit.ly/362UoxF While the function declaration and invocation above are nearly identical in TS and JS, the enum declaration trans-compiles to an IIFE with nested assignments to an object

## Tips and Tricks for working with Apollo Cache

DevFeed: [Tips and Tricks for working with Apollo Cache](<https://devfeed.tech/articles/tips-and-tricks-for-working-with-apollo-cache-19125.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/tips-and-tricks-for-working-with-apollo-cache-3b5a757f10a0?source=rss----904782439303---4>)

Author: Tommy Suwunrut

Published: 2020-10-29T19:16:34Z

Content type: article

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [apollo-client](<https://devfeed.tech/topics/apollo-client.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [cache-invalidation](<https://devfeed.tech/topics/cache-invalidation.md>), [GraphQL](<https://devfeed.tech/topics/graphql.md>)

Tags: [apollo](<https://devfeed.tech/tags/apollo.md>), [apollo-client](<https://devfeed.tech/tags/apollo-client.md>), [cache](<https://devfeed.tech/tags/cache.md>), [cache-invalidation](<https://devfeed.tech/tags/cache-invalidation.md>), [caching](<https://devfeed.tech/tags/caching.md>), [fetching](<https://devfeed.tech/tags/fetching.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [frontend-architecture](<https://devfeed.tech/tags/frontend-architecture.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [programming](<https://devfeed.tech/tags/programming.md>), [queries](<https://devfeed.tech/tags/queries.md>), [query](<https://devfeed.tech/tags/query.md>), [react](<https://devfeed.tech/tags/react.md>), [tips](<https://devfeed.tech/tags/tips.md>), [tips-and-tricks](<https://devfeed.tech/tags/tips-and-tricks.md>)

### AI overview

Apollo Client normalizes returned objects into a cache keyed by each object's identifier and `__typename`, and stores query results by query name and variables. This can make previously fetched data available immediately and let identical queries reuse cached results. When a task is added or updated, Apollo updates that task's object entry but does not automatically know which filtered collection query results to refresh or invalidate. The excerpt begins to introduce fetch policies as a way to address this, naming `cache-first`, `cache-and-network`, and `network`, but does not include their behaviors or compare approaches.

### Source excerpt

Photo by Stephen Walker on Unsplash With its declarative fetching, helpful tooling, extensive type definitions, and built-in integration with React, Apollo Client has played a fundamental role in simplifying frontend architecture over the past few years. Its built-in caching layer, which allows you to retrieve previously requested data without needing to make additional network requests to the server, has the potential to make any application feel snappier. Apollo even provides ways of warming up the cache to be used for later, freeing our frontends from the dreaded loading spinners. But cache invalidation is one of those notoriously difficult problems in any computer program, and trying to update or bust Apollo's cache after server-side updates is far from a perfect experience, especially when the queries being cached have many filters and constraints. Let's begin with an overview of how Apollo's cache works, and then discuss the tradeoffs involved with a few different approaches to working with it. Throughout this article we'll be using this Mock List application as a reference. Cache Keys When you make any graphQL query, by default Apollo caches the response in what it calls a flat, normalized lookup table. It constructs a unique identifier for each object returned from your query, by combining its id or _id properties with the __typename defined in your schema. So if the application above executes queries as the user types "G", then "Go", then "Go g", all the way to "Go groceries shopping", Apollo could potentially pull down information about many different tasks and cache each one roughly like this: Task:1234: { name: "Go grocery shopping" } Task:2345: { name: "Go to gym" } Task:3456: { name: "Learn GoLang" } This is great if the user navigates to a detail view about a given task, because there will already be some data immediately available. Apollo will also store the results of each of those individual queries, in case you make the same exact query again late

## 30 Keyboard Shortcuts to Turbocharge Your Team's Engineering Velocity

DevFeed: [30 Keyboard Shortcuts to Turbocharge Your Team's Engineering Velocity](<https://devfeed.tech/articles/30-keyboard-shortcuts-to-turbocharge-your-team-s-engineering-velocity-19119.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/developer-shortcuts-to-stay-away-from-the-mouse-for-mac-723e26eab9f9?source=rss----904782439303---4>)

Author: Mitch Posk

Published: 2020-09-30T01:45:26Z

Content type: article

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [software-development](<https://devfeed.tech/topics/software-development.md>), [Visual Studio Code](<https://devfeed.tech/topics/visual-studio-code.md>), [keyboard](<https://devfeed.tech/topics/keyboard.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [engineering-culture](<https://devfeed.tech/topics/engineering-culture.md>)

Tags: [code-navigation](<https://devfeed.tech/tags/code-navigation.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [engineering-velocity](<https://devfeed.tech/tags/engineering-velocity.md>), [keyboard](<https://devfeed.tech/tags/keyboard.md>), [keyboard-shortcuts](<https://devfeed.tech/tags/keyboard-shortcuts.md>), [shortcut-keys](<https://devfeed.tech/tags/shortcut-keys.md>), [shortcuts](<https://devfeed.tech/tags/shortcuts.md>), [software-development](<https://devfeed.tech/tags/software-development.md>), [team](<https://devfeed.tech/tags/team.md>), [velocity](<https://devfeed.tech/tags/velocity.md>), [web-development](<https://devfeed.tech/tags/web-development.md>)

### AI overview

The excerpt argues that sharing keyboard shortcuts can save developers time and improve team velocity, especially when colleagues work apart. Its visible Visual Studio Code advice includes moving the sidebar to the right to keep code from shifting when it opens, using the command palette to change the sidebar position, and opening Explorer, Search, Source Control, Debugger, or Extensions directly. It also distinguishes project-wide text search from filename search. Several key combinations are missing from the supplied text, so the exact shortcuts for these actions cannot be recovered here.

### Source excerpt

Photo by SpaceX on Unsplash Every developer knows a shortcut or two that makes the job just a little bit easier. While those new to the industry might dream of a time in the far-off future when their fingers are the limiting factor to their coding output, a seasoned veteran can light up a keyboard like a jazz musician improvising over a familiar melody. I've overheard engineers let out an audible gasp the first time they see a coworker lay down a novel key combination. The look on their face tells the entire story: Just think of how much time we could have saved! If only I'd known! Shortcuts allow us to spend more time focusing on the important aspects of software engineering -- and over the span of a career spent largely in front of a keyboard, they compound to save us hours, days, or even weeks of development time. When widely used across an engineering team, shortcuts can significantly increase engineering velocity and output. And yet, our tendency as developers is often to hoard them, holding them close like competing magicians guarding the secrets behind our sleight of hand. The goal of today's post is to pull back this curtain, and divulge a few favorite tricks of the trade. Now that we are less likely to be sharing the same physical space and picking up new techniques through office osmosis, I believe we have to become more explicit in sharing what works for us with our team mates. What follows are my most-used shortcuts that save me the most time. My hope is that you will find a few of them new and useful, and adopt them into your own repertoire. Visual Studio Code Navigation cmd + b is a shortcut to open or close the workbench sidebar. We do this about a million times a day, so the time it saves can add up quickly. But not only can we do it faster, we can do it better, too! By moving the sidebar to the right, you can keep your code from jumping all over the screen when it opens, and therefore maintain better flow and focus. Text remains in place with the Sid

## Who Turned on the Lights?

DevFeed: [Who Turned on the Lights?](<https://devfeed.tech/articles/who-turned-on-the-lights-19126.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/who-turned-on-the-lights-579c12fda6b?source=rss----904782439303---4>)

Author: Alejandra Del Valle

Published: 2020-08-20T19:06:20Z

Content type: tutorial

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [screen brightness](<https://devfeed.tech/topics/screen-brightness.md>), [React](<https://devfeed.tech/topics/react.md>), [Ionic](<https://devfeed.tech/topics/ionic.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [PWA](<https://devfeed.tech/topics/pwa.md>)

Tags: [2019](<https://devfeed.tech/tags/2019.md>), [android](<https://devfeed.tech/tags/android.md>), [capacitor](<https://devfeed.tech/tags/capacitor.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [ionic](<https://devfeed.tech/tags/ionic.md>), [ios](<https://devfeed.tech/tags/ios.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [pwa](<https://devfeed.tech/tags/pwa.md>), [react](<https://devfeed.tech/tags/react.md>), [react-hooks](<https://devfeed.tech/tags/react-hooks.md>), [screen-brightness](<https://devfeed.tech/tags/screen-brightness.md>)

### AI overview

The article shows how an Ionic React app can temporarily raise screen brightness for a QR-code page and restore the user's prior level when the app becomes inactive. It uses `@ionic-native/brightness` to read and set brightness, a custom `useBrightness` hook to save the initial value, and `@capacitor-community/react-hooks` to track app state. The excerpt includes setup commands for Ionic, the brightness plugin, and Capacitor iOS and Android projects, but omits the implementation code for the hook. The author flags an unresolved case: a user changing brightness while the app is already controlling it.

### Source excerpt

Manipulating Screen Brightness on iOS and Android Devices Undoubtedly one of the most annoying side effects our phones have is its ability to change screen brightness dynamically. Whether it's a setting enabled on your device to automatically adjust brightness based on your environment, or an app you downloaded manipulates it based on its needs, sometimes it's just out of your control. Maybe you're an avid digital content creator and having your screen brightness at its max is to help your content be "pixel-perfect" and edited just the way you want. Maybe you're visiting a store and need to scan your screen to quickly and easily pay for something without fumbling through your wallet or purse. Or, maybe you're at a show or at home for a movie night and having your screen brightness as low as possible is important to one, not blind you, and two, not blind your neighbors. Whatever the backstory, it's important for the apps we use to consider how we use our phones in our day-to-day lives to create a seamless experience that users will enjoy. Let's look at how we can help with this experience in native development using Ionic React with Ionic React Hooks (recently renamed to React Hooks for Capacitor). Keep reading if you have basic experience with React and React Hooks. If not, I would suggest getting familiar with React and then hop back on over! Why Ionic React? Short answer? Ionic React is ultimately just... React. Music to my ears. Ionic React is also built using web components, making it compatible with a multitude of web libraries and supports iOS, Android, Desktop, and PWA (i.e. progressive web apps) all by using one shared codebase (I'm hearing music again...). Ionic React Hooks Re-introduced Ionic announced their launch of Ionic React Hooks back in December of 2019. It has recently been renamed and moved to the Capacitor Community org -- @capacitor-community/react-hooks. This package provides a collection of wrappers around Capacitor APIs along with a few other Ioni

## Theme with styled-components and Typescript

DevFeed: [Theme with styled-components and Typescript](<https://devfeed.tech/articles/theme-with-styled-components-and-typescript-19124.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/theme-with-styled-components-and-typescript-209244ec15a3?source=rss----904782439303---4>)

Author: Ethan Nguyen

Published: 2020-07-14T12:58:19Z

Content type: tutorial

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [styled-components](<https://devfeed.tech/topics/styled-components.md>), [Design system](<https://devfeed.tech/topics/design-system.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>), [Visual Studio Code](<https://devfeed.tech/topics/visual-studio-code.md>)

Tags: [css-in-js](<https://devfeed.tech/tags/css-in-js.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [design-patterns](<https://devfeed.tech/tags/design-patterns.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [multiple](<https://devfeed.tech/tags/multiple.md>), [setup](<https://devfeed.tech/tags/setup.md>), [styled-components](<https://devfeed.tech/tags/styled-components.md>), [themes](<https://devfeed.tech/tags/themes.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

### AI overview

The excerpt outlines how to set up theming with styled-components and TypeScript: define a DefaultTheme interface in a declaration file to provide IntelliSense and a contract for theme values, then use a theme object with ThemeProvider around the root app. It recommends basing theme fields on design choices such as border radius, typography, and color roles, using names like "primary" or "secondary" rather than literal color names. It treats common neutral colors such as black and white as exceptions. The excerpt mentions a VS Code plugin for styled-components syntax highlighting and IntelliSense; later theme creation and switching examples are only partially shown.

### Source excerpt

What is styled-components? Styled-components is arguably the most common CSS-in-JS library out there (Don't trust me? Check out their site and their adoption from many organizations, 7.6M/month downloads on NPM 🔥). One of its advanced use cases for this library is theming. Theming in styled-components allows your app to support multiple design patterns within the same app. Imagine an amazing code editor with no dark mode! Having options to customize the look and feel of your app from the primary colour palette to the typography scale can help our system to capture more personas. This article will give some breakdown of the basic setup and naming convention for theming your app with styled-components, and how to setup Typescript with styled-components themes Installationyarn add styled-components yarn add @types/styled-components -DVSCode plugin If you are using Visual Studio Code, I highly recommend installing this helpful plugin. It will highlight and IntelliSense your syntax for styled-components Create a declaration file Firstly, we will need to define how our theme interface looks like. Inside src folder, create styled.d.ts file and extend the existing styled-component DefaultTheme. This will help with IntelliSense and ensure a contract for all available themes. // styled.d.ts import 'styled-components';interface IPalette { main: string contrastText: string }declare module 'styled-components' { export interface DefaultTheme { borderRadius: string palette: { common: { black: string white: string } primary: IPalette secondary: IPalette } } }Naming convention Let's break down some logic here for the naming convention of theming. As I mentioned earlier, our goal for theming a system is to be able to control the compactness and colour palette. Hence we should define our theme around these styles like border-radius font-weight font-size ... and all colour related. About colour naming, avoid naming variable with actual colour but do name with something likeprimary or sec

## Safari's 100vh Problem

DevFeed: [Safari's 100vh Problem](<https://devfeed.tech/articles/safari-s-100vh-problem-19122.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/safaris-100vh-problem-3412e6f13716?source=rss----904782439303---4>)

Author: Jon Rose

Published: 2020-06-17T19:14:35Z

Content type: article

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [mobile optimization](<https://devfeed.tech/topics/mobile-optimization.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>)

Tags: [100vh](<https://devfeed.tech/tags/100vh.md>), [apple](<https://devfeed.tech/tags/apple.md>), [browser](<https://devfeed.tech/tags/browser.md>), [css](<https://devfeed.tech/tags/css.md>), [css3](<https://devfeed.tech/tags/css3.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [layouts](<https://devfeed.tech/tags/layouts.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [positioning](<https://devfeed.tech/tags/positioning.md>), [responsive](<https://devfeed.tech/tags/responsive.md>), [safari](<https://devfeed.tech/tags/safari.md>), [scrolling](<https://devfeed.tech/tags/scrolling.md>), [viewport](<https://devfeed.tech/tags/viewport.md>)

### AI overview

On mobile Safari, 100vh stays constant as the browser button bar hides and appears, so the bar can cover content positioned using viewport height. The article says Safari chose this behavior to avoid layout jank from a changing viewport. For a footer or navbar, it suggests positioning instead of using height. For content that gets cut off, it describes setting section heights to window.innerHeight after page load and updating them on resize; this works but can itself look janky as heights change. The article favors avoiding layouts that depend on content at the bottom of the viewport, while noting workarounds such as React's Div100vh and the tradeoff of working against the browser's behavior.

### Source excerpt

Safari, being an Apple product, tends to "Think Different". Given Apple's dominant market share, especially in the US, it's important that we understand these differences, and know how to work with them. In this blog post, we're going to tackle the 100vh problem. 100vh Quick recap. The vh unit, introduced with CSS3, allows you to specify the percent of the total viewport's height. So 100vh would be 100% of the viewport. It's mobile responsive and has made building layouts much easier. Navbar Problem Let's try making a simple homepage with a footer for navigation. https://medium.com/media/cff698e095a28a6928ff7148fc3c694d/href In the main element is our content. We give it a height of 95vh or 95% of the total height. The footer gets the remaining 5% of the viewport. If we load this up on a desktop, it works exactly as expected. Checking Safari on mobile and we see: Why? This must be a bug, right? Well, no. This is actually a feature. When working on Safari, the team worked hard to show the button bar only when necessary. Their goal was to give more space to the website whenever possible, which is why the button bar hides when scrolling. This lead to a tough decision about how the viewport's height would be handled. Would it: 1. change the height every time the bar hides and shows or 2. make the viewport height constant, and have the button bar cover part of the viewport They opted for a constant height to avoid jankiness. This means that our navbar is in fact there, just hidden behind the button bar. When the button bar hides, we can see the navbar really was there. Navbar Solution So what do we do? Instead of placing our navbar by using height, we use positioning instead. https://medium.com/media/20c4987011013a9c0c01fd1b0ce9aceb/href Checking it out on desktop and we can see nothing changed: And now on mobile, we finally get what we expect. Content Problem The navbar example is a bit contrived. Hopefully you wouldn't use height for positioning regardless of the 100vh

## Wrangling Wild CMS Data with TypeScript

DevFeed: [Wrangling Wild CMS Data with TypeScript](<https://devfeed.tech/articles/wrangling-wild-cms-data-with-typescript-19127.md>)

Original publisher: [Read original article](<https://medium.com/rbi-tech/wrangling-wild-cms-data-with-typescript-a4bf0ac93467?source=rss----904782439303---4>)

Author: Pedro De Ona

Published: 2020-06-17T19:13:47Z

Content type: article

Language: en

Sources: [RBI Tech](<https://devfeed.tech/sources/rbi-tech.md>)

Topics: [TypeScript](<https://devfeed.tech/topics/typescript.md>), [data type](<https://devfeed.tech/topics/data-type.md>), [Data Management](<https://devfeed.tech/topics/data-management.md>)

Tags: [cms](<https://devfeed.tech/tags/cms.md>), [content-management-system](<https://devfeed.tech/tags/content-management-system.md>), [data](<https://devfeed.tech/tags/data.md>), [developer-experience](<https://devfeed.tech/tags/developer-experience.md>), [graphql](<https://devfeed.tech/tags/graphql.md>), [interface](<https://devfeed.tech/tags/interface.md>), [missing-values](<https://devfeed.tech/tags/missing-values.md>), [null](<https://devfeed.tech/tags/null.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

### AI overview

Real-time CMS edits can leave null or missing values in data that drives both website content and business-critical features. The excerpt presents several TypeScript approaches: optional chaining with `??` supplies a fallback for display while preserving intentional empty strings; refinement functions (type guards) can validate offers, and using one with `Array.prototype.filter` narrows the resulting list to valid offers before downstream code uses it. A recursive mapped type using `Exclude` can derive a corresponding type with null values removed, including for arrays. These techniques address different needs: fallbacks ease display handling, while validation is more appropriate when invalid data could break ordering. The excerpt does not show the referenced GraphQL interface or the full validation example.

### Source excerpt

Attempting to get the CMS under control Here at RBI, we've prioritized building a software platform that enables us to rapidly deliver high value. Sometimes this means literally delivering valuable food to your waiting stomachs, but for software engineers, it also means delivering a highly customizable web platform to our internal marketing teams, which allows us to drive dynamic customer experiences with minimal engineering effort. To that end, one of the products that we incorporate in our tech stack is a CMS. Classic Three-letter Acronym A CMS, or content management system, can be used in a variety of ways. At RBI we primarily use it to allow our digital marketing and product teams to control the content we deliver on our websites in real-time. This can be both a boon and a curse. On the one hand, it enables us to curate and create new experiences without needing to wait for deployment, but on the other, it means our code needs to be prepared to deal with some pretty unpredictable data. Oftentimes, this data is simply used to control the display of content to the user, but we also use it to drive some pretty core functionality like our digital menu, and this is where things can become problematic. CMS data is edited by humans and published in real-time, which means null or missing values in data are an unfortunate reality, and if not dealt with proactively, can lead to production failures. To that end, we rely on TypeScript and GraphQL as two technologies that increase our confidence in the features we ship. These tools can work hand-in-hand to create an excellent developer experience and help ensure you are writing sound and correct code. They Can, But Do They? That being said, sometimes the harsh reality of typed code can be more of a thorn in one's side than a brilliant shining beacon, guiding you to feature completion. Take the following interface, derived automatically from a GraphQL operation, as an example: https://medium.com/media/a0635a0c94916a7504311adc